summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSagar Patel <sagarmp@cs.unc.edu>2022-03-23 16:06:05 -0700
committerAlejandro Colomar <alx.manpages@gmail.com>2022-08-15 16:33:56 +0200
commit2d5c41ee72bd302007b950cb90a0e6d3a9e43366 (patch)
tree5c2021a824cb634b82ba7a93cea127dd1ecc69e6
parent2c803b62c390f8274a9eb3417ee03ead71eb76db (diff)
checkpatch: use python3 to find codespell dictionary
Commit 0ee3e7b8893e ("checkpatch: get default codespell dictionary path from package location") introduced the ability to search for the codespell dictionary rather than hardcoding its path. codespell requires Python 3.6 or above, but on some systems, the python executable is a Python 2.7 interpreter. In this case, searching for the dictionary fails, subsequently making codespell fail: No codespell typos will be found - file '/usr/share/codespell/dictionary.txt': No such file or directory So, use python3 to remove ambiguity. In addition, when searching for dictionary.txt, do not check if the codespell executable exists since, - checkpatch.pl only uses dictionary.txt, not the codespell executable. - codespell can be installed via a Python package manager, in which case the codespell executable may not be present in a typical $PATH, but a dictionary does exist. Link: https://lkml.kernel.org/r/20220309180048.147672-1-sagarmp@cs.unc.edu Signed-off-by: Sagar Patel <sagarmp@cs.unc.edu> Reviewed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Cc: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
-rwxr-xr-xscripts/checkpatch.pl4
1 files changed, 2 insertions, 2 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2653177..577e029 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -334,7 +334,7 @@ if ($user_codespellfile) {
} elsif (!(-f $codespellfile)) {
# If /usr/share/codespell/dictionary.txt is not present, try to find it
# under codespell's install directory: <codespell_root>/data/dictionary.txt
- if (($codespell || $help) && which("codespell") ne "" && which("python") ne "") {
+ if (($codespell || $help) && which("python3") ne "") {
my $python_codespell_dict = << "EOF";
import os.path as op
@@ -344,7 +344,7 @@ codespell_file = op.join(codespell_dir, 'data', 'dictionary.txt')
print(codespell_file, end='')
EOF
- my $codespell_dict = `python -c "$python_codespell_dict" 2> /dev/null`;
+ my $codespell_dict = `python3 -c "$python_codespell_dict" 2> /dev/null`;
$codespellfile = $codespell_dict if (-f $codespell_dict);
}
}