[issue4626] compile() doesn't ignore the source encoding when a string is passed in

Benjamin Peterson report at bugs.python.org
Mon Feb 23 02:41:00 CET 2009


Benjamin Peterson <benjamin at python.org> added the comment:

On Tue, Feb 17, 2009 at 6:22 PM, STINNER Victor <report at bugs.python.org> wrote:
> I don't understand the change in source_as_string(). Except of that,
> it looks correct.

Py_CFFLAGS_SOURCE_IS_UTF8 is already set in compile().

>
>> The one problem is that it causes test_coding to fail because
>> coding cookies are ignored and not checked to see if they
>> are the same as the encoding of the file.
>
> The test have to fail, but the error is not the the compile() patch,
> but in the test. Input file is opened as unicode instead of bytes. A
> propose this patch to fix the test:

That fix is correct, but I think it avoids what the test is meant to
test. The test is supposed to check that compile() complains if the
encoding of the unicode string is wrong compared to the coding cookie,
but I think that feature is ok to not support.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4626>
_______________________________________


More information about the Python-bugs-list mailing list