Programs in UTF-8 with no declared coding are accepted

Bug #1608595 reported by Aaron Crane
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pyflakes
New
Undecided
Unassigned

Bug Description

If a program's source uses UTF-8, but the file's encoding is not declared using a `coding` declaration, Pyflakes accepts the program as valid, even though Python itself refuses it.

$ file coding.py
coding.py: UTF-8 Unicode text
$ cat coding.py
print "¡this file contains ŭnicode!"
$ pyflakes --version
1.2.3
$ pyflakes coding.py
$ python coding.py
  File "coding.py", line 1
SyntaxError: Non-ASCII character '\xc2' in file coding.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
$

Expected outcome: Pyflakes should report a syntax error for such files.

Revision history for this message
Aaron Crane (aaroncrane) wrote :
Revision history for this message
Ian Cordasco (icordasc) wrote :

What version of Python are you using and what version of Python is PyFlakes installed on?

Revision history for this message
Aaron Crane (aaroncrane) wrote :

Both are Python 2.7.12

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

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