Cannot handle non-ascii strings in source code

Bug #776389 reported by Henning Eggers
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pocket-lint
Fix Released
High
Henning Eggers

Bug Description

Pocket-lint trips over source files with non-ascii characters in it. The example contained "português". It probably needs to honor PEP 0263.

Traceback (most recent call last):
  File "/usr/bin/pocketlint", line 6, in <module>
    sys.exit(main(sys.argv))
  File "/usr/lib/pymodules/python2.7/pocketlint/formatcheck.py", line 557, in main
    check_sources(sources, reporter)
  File "/usr/lib/pymodules/python2.7/pocketlint/formatcheck.py", line 542, in check_sources
    checker.check()
  File "/usr/lib/pymodules/python2.7/pocketlint/formatcheck.py", line 224, in check
    PythonChecker(self.file_path, self.text, self._reporter).check()
  File "/usr/lib/pymodules/python2.7/pocketlint/formatcheck.py", line 416, in check
    self.check_text()
  File "/usr/lib/pymodules/python2.7/pocketlint/formatcheck.py", line 465, in check_text
    self.check_ascii(line_no, line)
  File "/usr/lib/pymodules/python2.7/pocketlint/formatcheck.py", line 479, in check_ascii
    ascii_line = line.encode('ascii')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 29: ordinal not in range(128)

Related branches

Revision history for this message
Curtis Hovey (sinzui) wrote :

which kind of source file? The Python checker does do an encoding check...ascii, or the encoding specified at the start of the file? This rule also applies to doctests.

Changed in pocket-lint:
status: New → Incomplete
Revision history for this message
Curtis Hovey (sinzui) wrote :

If this is a python or doctest file, can you paste the encoding line, eg:
    # -*-

Revision history for this message
Henning Eggers (henninge) wrote :

It was python file and its first line was:
# coding=utf-8

That is what PEP 0263 requires. Alternatively it allows "formats recognized by popular editors", one of which is the -*- you suggested. So I guess the bug is that not all formats allowed by PEP 0263 are supported.

I'll have a look at the source code.

Changed in pocket-lint:
status: Incomplete → In Progress
assignee: nobody → Henning Eggers (henninge)
Curtis Hovey (sinzui)
Changed in pocket-lint:
milestone: none → 0.5.16
importance: Undecided → High
status: In Progress → Fix Committed
Curtis Hovey (sinzui)
Changed in pocket-lint:
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.