[
https://issues.apache.org/jira/browse/HADOOP-12303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14695679#comment-14695679
]
Kengo Seki commented on HADOOP-12303:
-------------------------------------
In the above situation, pylint returns 1.
{code}
[sekikn@mobile hadoop]$ pylint dev-support/releasedocmaker.py >/dev/null
No config file found, using default configuration
Traceback (most recent call last):
File "/usr/local/bin/pylint", line 11, in <module>
sys.exit(run_pylint())
File "/Library/Python/2.7/site-packages/pylint/__init__.py", line 23, in
run_pylint
Run(sys.argv[1:])
File "/Library/Python/2.7/site-packages/pylint/lint.py", line 1332, in
__init__
linter.check(args)
File "/Library/Python/2.7/site-packages/pylint/lint.py", line 747, in check
self._do_check(files_or_modules)
File "/Library/Python/2.7/site-packages/pylint/lint.py", line 869, in
_do_check
self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
File "/Library/Python/2.7/site-packages/pylint/lint.py", line 944, in
check_astroid_module
checker.process_tokens(tokens)
File "/Library/Python/2.7/site-packages/pylint/checkers/format.py", line 727,
in process_tokens
self.new_line(TokenWrapper(tokens), idx-1, idx+1)
File "/Library/Python/2.7/site-packages/pylint/checkers/format.py", line 473,
in new_line
self.check_lines(line, line_num)
File "/Library/Python/2.7/site-packages/pylint/checkers/format.py", line 932,
in check_lines
self.add_message('line-too-long', line=i, args=(len(line), max_chars))
File "/Library/Python/2.7/site-packages/pylint/checkers/__init__.py", line
101, in add_message
self.linter.add_message(msg_id, line, node, args, confidence)
File "/Library/Python/2.7/site-packages/pylint/utils.py", line 410, in
add_message
(abspath, path, module, obj, line or 1, col_offset or 0), msg, confidence))
File "/Library/Python/2.7/site-packages/pylint/reporters/text.py", line 61,
in handle_message
self.write_message(msg)
File "/Library/Python/2.7/site-packages/pylint/reporters/text.py", line 51,
in write_message
self.writeln(msg.format(self._template))
File "/Library/Python/2.7/site-packages/pylint/reporters/__init__.py", line
94, in writeln
print(self.encode(string), file=self.out)
File "/Library/Python/2.7/site-packages/pylint/reporters/__init__.py", line
84, in encode
locale.getdefaultlocale()[1] or
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py",
line 511, in getdefaultlocale
return _parse_localename(localename)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py",
line 443, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
[sekikn@mobile hadoop]$ echo $?
1
{code}
But pylint can also return 1 even if linting succeeded.
{code}
[sekikn@mobile hadoop]$ cat a.py
"""a.py"""
import simplejson
print dir(simplejson)
[sekikn@mobile hadoop]$ pylint --reports=n a.py
No config file found, using default configuration
************* Module a
F: 2, 0: Unable to import 'simplejson' (import-error)
[sekikn@mobile hadoop]$ echo $?
1
{code}
So the status code doesn't help, though this example is somewhat artificial.
Probably we need to distinguish them by the stderr contents.
> test-patch pylint plugin fails silently and votes +1 incorrectly
> ----------------------------------------------------------------
>
> Key: HADOOP-12303
> URL: https://issues.apache.org/jira/browse/HADOOP-12303
> Project: Hadoop Common
> Issue Type: Sub-task
> Components: yetus
> Affects Versions: HADOOP-12111
> Reporter: Kengo Seki
>
> This patch
> {code}
> [sekikn@mobile hadoop]$ cat /tmp/test.patch
> diff --git a/dev-support/releasedocmaker.py b/dev-support/releasedocmaker.py
> index 37bd58a..7cd6dd3 100755
> --- a/dev-support/releasedocmaker.py
> +++ b/dev-support/releasedocmaker.py
> @@ -580,4 +580,4 @@ def main():
> sys.exit(1)
>
> if __name__ == "__main__":
> - main()
> + main( )
> {code}
> is supposed to cause the following pylint errors.
> {code}
> C:583, 0: No space allowed after bracket
> main( )
> ^ (bad-whitespace)
> C:583, 0: No space allowed before bracket
> main( )
> ^ (bad-whitespace)
> {code}
> But the system locale is set as follows, pylint check is passed, and there is
> no pylint output.
> {code}
> [sekikn@mobile hadoop]$ locale
> LANG=
> LC_COLLATE="C"
> LC_CTYPE="UTF-8"
> LC_MESSAGES="C"
> LC_MONETARY="C"
> LC_NUMERIC="C"
> LC_TIME="C"
> LC_ALL=
> [sekikn@mobile hadoop]$ dev-support/test-patch.sh
> --basedir=/Users/sekikn/dev/hadoop --project=hadoop /tmp/test.patch
> (snip)
> | Vote | Subsystem | Runtime | Comment
> ============================================================================
> | +1 | @author | 0m 00s | The patch does not contain any @author
> | | | | tags.
> | +1 | asflicense | 0m 21s | Patch does not generate ASF License
> | | | | warnings.
> | +1 | pylint | 0m 01s | There were no new pylint issues.
> | +1 | whitespace | 0m 00s | Patch has no whitespace issues.
> | | | 0m 24s |
> (snip)
> [sekikn@mobile hadoop]$ cat
> /private/tmp/test-patch-hadoop/8656/branch-pylint-result.txt
> [sekikn@mobile hadoop]$ cat
> /private/tmp/test-patch-hadoop/8656/patch-pylint-result.txt
> [sekikn@mobile hadoop]$ cat
> /private/tmp/test-patch-hadoop/8656/diff-patch-pylint.txt
> {code}
> Removing '2>/dev/null' from pylint.sh reveals the root cause. Setting LC_ALL
> or LC_CTYPE such like 'en_US.UTF-8' solves this problem.
> {code}
> ============================================================================
> ============================================================================
> pylint plugin: prepatch
> ============================================================================
> ============================================================================
> ============================================================================
> Running pylint against modified python scripts.
> No config file found, using default configuration
> Traceback (most recent call last):
> File "/usr/local/bin/pylint", line 11, in <module>
> sys.exit(run_pylint())
> File "/Library/Python/2.7/site-packages/pylint/__init__.py", line 23, in
> run_pylint
> Run(sys.argv[1:])
> File "/Library/Python/2.7/site-packages/pylint/lint.py", line 1332, in
> __init__
> linter.check(args)
> File "/Library/Python/2.7/site-packages/pylint/lint.py", line 747, in check
> self._do_check(files_or_modules)
> File "/Library/Python/2.7/site-packages/pylint/lint.py", line 869, in
> _do_check
> self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
> File "/Library/Python/2.7/site-packages/pylint/lint.py", line 944, in
> check_astroid_module
> checker.process_tokens(tokens)
> File "/Library/Python/2.7/site-packages/pylint/checkers/format.py", line
> 743, in process_tokens
> self.check_indent_level(token, indents[-1]+1, line_num)
> File "/Library/Python/2.7/site-packages/pylint/checkers/format.py", line
> 963, in check_indent_level
> expected * unit_size))
> File "/Library/Python/2.7/site-packages/pylint/checkers/__init__.py", line
> 101, in add_message
> self.linter.add_message(msg_id, line, node, args, confidence)
> File "/Library/Python/2.7/site-packages/pylint/utils.py", line 410, in
> add_message
> (abspath, path, module, obj, line or 1, col_offset or 0), msg,
> confidence))
> File "/Library/Python/2.7/site-packages/pylint/reporters/text.py", line 61,
> in handle_message
> self.write_message(msg)
> File "/Library/Python/2.7/site-packages/pylint/reporters/text.py", line 51,
> in write_message
> self.writeln(msg.format(self._template))
> File "/Library/Python/2.7/site-packages/pylint/reporters/__init__.py", line
> 94, in writeln
> print(self.encode(string), file=self.out)
> File "/Library/Python/2.7/site-packages/pylint/reporters/__init__.py", line
> 84, in encode
> locale.getdefaultlocale()[1] or
> File
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py",
> line 511, in getdefaultlocale
> return _parse_localename(localename)
> File
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py",
> line 443, in _parse_localename
> raise ValueError, 'unknown locale: %s' % localename
> ValueError: unknown locale: UTF-8
> {code}
> In such a case, pylint plugin should fail and vote -1.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)