New submission from Jakub Wilk: 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 ---------- messages: 205795 nosy: jwilk priority: normal severity: normal status: open title: UTF-8 encoding not enforced versions: Python 2.7 _______________________________________ Python tracker <[email protected]> <http://bugs.python.org/issue19942> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
