Reporting errors in non-ASCII filenames fails

Bug #1170459 reported by Ville Skyttä
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pyflakes
Fix Released
Medium
Unassigned

Bug Description

This is with pyflakes 0.7, Python 2.7.3, LANG=en_US.UTF-8 on Fedora 17:

$ pyflakes pöö
Traceback (most recent call last):
  File "/usr/bin/pyflakes", line 9, in <module>
    load_entry_point('pyflakes==0.7', 'console_scripts', 'pyflakes')()
  File "/usr/lib/python2.7/site-packages/pyflakes/api.py", line 129, in main
    warnings = checkRecursive(args, reporter)
  File "/usr/lib/python2.7/site-packages/pyflakes/api.py", line 120, in checkRecursive
    warnings += checkPath(sourcePath, reporter)
  File "/usr/lib/python2.7/site-packages/pyflakes/api.py", line 86, in checkPath
    reporter.unexpectedError(filename, msg.args[1])
  File "/usr/lib/python2.7/site-packages/pyflakes/reporter.py", line 40, in unexpectedError
    self._stderr.write(u("%s: %s\n") % (filename, msg))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

0.6.1 fails the same way, but 0.5 works:

$ pyflakes pöö
pöö: No such file or directory

Related branches

Revision history for this message
Florent (florent.x) wrote :

Confirmed with Python 2.x

Changed in pyflakes:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Ville Skyttä (vskytta) wrote :

Fix otherwise confirmed, but if stderr is redirected to a file it still fails:

$ pyflakes pöö 2>stderr.out
$ cat stderr.out
Traceback (most recent call last):
  File "/usr/bin/pyflakes", line 9, in <module>
    load_entry_point('pyflakes==0.7.1a0', 'console_scripts', 'pyflakes')()
  File "/usr/lib/python2.7/site-packages/pyflakes/api.py", line 129, in main
    warnings = checkRecursive(args, reporter)
  File "/usr/lib/python2.7/site-packages/pyflakes/api.py", line 120, in checkRecursive
    warnings += checkPath(sourcePath, reporter)
  File "/usr/lib/python2.7/site-packages/pyflakes/api.py", line 86, in checkPath
    reporter.unexpectedError(filename, msg.args[1])
  File "/usr/lib/python2.7/site-packages/pyflakes/reporter.py", line 45, in unexpectedError
    _write(self._stderr, "%s: %s\n" % (filename, msg))
  File "/usr/lib/python2.7/site-packages/pyflakes/reporter.py", line 11, in _write
    stream.write(text.decode(encoding, 'replace'))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 1-2: ordinal not in range(128)

Revision history for this message
Florent (florent.x) wrote :

Thank you for this review.

I've reworked the fix, and it seems to work better in all cases.

Florent (florent.x)
Changed in pyflakes:
milestone: none → 0.7.x
status: Confirmed → In Progress
Florent (florent.x)
Changed in pyflakes:
status: In Progress → Fix Committed
Florent (florent.x)
Changed in pyflakes:
milestone: 0.7.x → 0.7.1
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.