[issue19941] python -m imports non-ASCII .py file without encoding declaration
STINNER Victor
report at bugs.python.org
Tue Nov 30 19:45:37 EST 2021
STINNER Victor <vstinner at python.org> added the comment:
I confirm: Python 3.10 works as expected.
Python 3.10 fails with the same SyntaxError using "python script.py" or "python -m script" if the script contains non-ASCII characters but is not encoded to UTF-8.
vstinner at apu$ python3 test.py
File "/home/vstinner/test.py", line 1
print('�Hello world!')
^
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xa1 in position 0: invalid start byte
vstinner at apu$ python3 -m test
Traceback (most recent call last):
(...)
File "/home/vstinner/test.py", line 1
print('�Hello world!')
^
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xa1 in position 0: invalid start byte
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue19941>
_______________________________________
More information about the Python-bugs-list
mailing list