Skip to content

Pythoscope fails on non-ASCII python files #10

@onnokort

Description

@onnokort

Hi,

first of all, Pythoscope looks like an awesome idea, a pity that it seems to have been unmaintained for so long. I hope I am submitting bugs at the right location here, as the launchpad bug tracker seems to be seriously out of date?

While trying it out, I noticed it fails on encountering files with a non-ASCII encoding, or at least one with an UTF-8 encoding.

Here is an example file:
test123.py

Error message is:

INFO: Inspecting module test123.py.
ERROR: Oops, it seems that an internal Pythoscope error occurred. Please file a bug report at https://bugs.launchpad.net/pythoscope

Traceback (most recent call last):
File "/home/xxx/.local/bin/pythoscope", line 11, in
sys.exit(main())
File "/home/xxx/.local/lib/python2.7/site-packages/pythoscope/init.py", line 184, in main
init_project(project_path)
File "/home/xxx/.local/lib/python2.7/site-packages/pythoscope/init.py", line 112, in init_project
inspect_project_statically(project)
File "/home/xxx/.local/lib/python2.7/site-packages/pythoscope/inspector/init.py", line 55, in inspect_project_statically
return add_and_update_modules(project) +
File "/home/xxx/.local/lib/python2.7/site-packages/pythoscope/inspector/init.py", line 37, in add_and_update_modules
static.inspect_module(project, modpath)
File "/home/xxx/.local/lib/python2.7/site-packages/pythoscope/inspector/static.py", line 130, in inspect_module
return inspect_code(project, path, read_file_contents(path))
File "/home/xxx/.local/lib/python2.7/site-packages/pythoscope/inspector/static.py", line 135, in inspect_code
tree = parse(code)
File "/home/xxx/.local/lib/python2.7/site-packages/pythoscope/astbuilder.py", line 82, in parse
result = drv.parse_string(code, True)
File "/usr/lib/python2.7/lib2to3/pgen2/driver.py", line 106, in parse_string
return self.parse_tokens(tokens, debug)
File "/usr/lib/python2.7/lib2to3/pgen2/driver.py", line 60, in parse_tokens
prefix += value
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2: ordinal not in range(128)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions