This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jwilk
Recipients jwilk
Date 2013-12-10.11:48:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1386676139.88.0.227932494666.issue19942@psf.upfronthosting.co.za>
In-reply-to
Content
I created a Python file which contained a non-UTF-8 string literal (but no Unicode literals), and added "UTF-8" encoding declaration to it. I expected that Python will raise SyntaxError when importing such module, but it doesn't:

$ python --version
Python 2.7.6

$ python -c 'import test1' && echo ok
ok


Curiously enough, if I change the declaration to "UTF8", then the exception is raised as expected:

$ sed -e 's/UTF-8/UTF8/' < test1.py > test2.py
$ python -c 'import test2'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "test2.py", line 2
SyntaxError: 'utf8' codec can't decode byte 0xa1 in position 5: invalid start byte
History
Date User Action Args
2013-12-10 11:48:59jwilksetrecipients: + jwilk
2013-12-10 11:48:59jwilksetmessageid: <1386676139.88.0.227932494666.issue19942@psf.upfronthosting.co.za>
2013-12-10 11:48:59jwilklinkissue19942 messages
2013-12-10 11:48:59jwilkcreate