[New-bugs-announce] [issue6289] compile() raises SyntaxError with confusing message for some decoding problems
Jean-Paul Calderone
report at bugs.python.org
Tue Jun 16 00:22:40 CEST 2009
New submission from Jean-Paul Calderone <exarkun at divmod.com>:
Consider this source file:
# coding: ascii
☃
It is not a valid Python program (for several reasons). The first
problem encountered is that bytes representing SNOWMAN do not fit into
ASCII, so the file cannot be decoded using the declared encoding.
If one tries to import this file, a reasonable thing happens:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "encodingfoo.py", line 2
SyntaxError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal
not in range(128)
If the builtin compile() is used instead, though, something different
happens:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 0
SyntaxError: unknown encoding: ascii
----------
components: Library (Lib)
messages: 89417
nosy: exarkun
severity: normal
status: open
title: compile() raises SyntaxError with confusing message for some decoding problems
type: behavior
versions: Python 2.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6289>
_______________________________________
More information about the New-bugs-announce
mailing list