give error when file cxoding declaration is missing
Given the following one-line Python program…
print(u'└─┘')
When run with PyPy 7.3.1 (Python 2.7.13), its output is:
âââ
(Note: Some characters omitted because they caused an HTTP 500 error when I tried to submit this issue.)
I spent a lot of time trying to figure out why PyPy wouldn't print the string as expected. Then I thought of trying to run the program with CPython 2.7.10 instead of PyPy. The result was the error message:
SyntaxError: Non-ASCII character '\xe2' in file unicode_test.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
So, by adding the # -*- coding: UTF-8 -*-
line I'd forgotten at the beginning of the program, when I run it under PyPy or CPython, I received the expected output:
└─┘
Rather than giving unreasonable output, PyPy should give an error message just as CPython does. It would save a lot of debugging time.