pylint-bot / pylint-unofficial

UNOFFICIAL playground for pylint github migration
0 stars 0 forks source link

non-ascii characters break MultipleTypesChecker #724

Closed pylint-bot closed 8 years ago

pylint-bot commented 8 years ago

Originally reported by: BitBucket: carlio, GitHub: @carlio?


If a class definition includes non-ascii characters, conversion in as_string fails. As far as I can tell this is only due to the new MultipleTypesChecker but will add comments if I find more instances.

  File "/tmp/test/venv/bin/pylint", line 11, in <module>
    sys.exit(run_pylint())
  File "/tmp/test/venv/lib/python2.7/site-packages/pylint/__init__.py", line 23, in run_pylint
    Run(sys.argv[1:])
  File "/tmp/test/venv/lib/python2.7/site-packages/pylint/lint.py", line 1315, in __init__
    linter.check(args)
  File "/tmp/test/venv/lib/python2.7/site-packages/pylint/lint.py", line 734, in check
    self._do_check(files_or_modules)
  File "/tmp/test/venv/lib/python2.7/site-packages/pylint/lint.py", line 865, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/tmp/test/venv/lib/python2.7/site-packages/pylint/lint.py", line 945, in check_astroid_module
    walker.walk(ast_node)
  File "/tmp/test/venv/lib/python2.7/site-packages/pylint/utils.py", line 938, in walk
    self.walk(child)
  File "/tmp/test/venv/lib/python2.7/site-packages/pylint/utils.py", line 935, in walk
    cb(astroid)
  File "/tmp/test/venv/lib/python2.7/site-packages/pylint/checkers/base.py", line 1946, in visit_assign
    if var_type == astroid.YES or var_type.as_string() == 'None':
  File "/tmp/test/venv/lib/python2.7/site-packages/astroid/bases.py", line 611, in as_string
    return to_code(self)
  File "/tmp/test/venv/lib/python2.7/site-packages/astroid/as_string.py", line 79, in __call__
    return node.accept(self)
  File "/tmp/test/venv/lib/python2.7/site-packages/astroid/bases.py", line 395, in accept
    return func(self)
  File "/tmp/test/venv/lib/python2.7/site-packages/astroid/as_string.py", line 163, in visit_classdef
    self._stmt_list(node.body))
  File "/tmp/test/venv/lib/python2.7/site-packages/astroid/as_string.py", line 83, in _stmt_list
    stmts = '\n'.join([nstr for nstr in [n.accept(self) for n in stmts] if nstr])
  File "/tmp/test/venv/lib/python2.7/site-packages/astroid/bases.py", line 395, in accept
    return func(self)
  File "/tmp/test/venv/lib/python2.7/site-packages/astroid/as_string.py", line 296, in visit_functiondef
    body=self._stmt_list(node.body))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 372: ordinal not in range(128)

This test case shows the error. You'll need to install github3.py, which has non-ascii apostrophes in docstrings. If you replace those non-ascii characters, everything runs fine.

from github3 import GitHub

def get_a_class():
  return GitHub()

x = 1
x = get_a_class()

pylint-bot commented 8 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


Could you try with this commit and see if it reproduces any longer? https://bitbucket.org/logilab/astroid/commits/b83a3b9fe44d6a6a65e1d10d9171097a2a4bb886

pylint-bot commented 8 years ago

Original comment by BitBucket: carlio, GitHub: @carlio?:


Ah, yes, that fixes it, thanks! Sorry for the noise :)