Message7581
The compile() function doesn't pay attention to the unicode_literals flag. It still parses str literals as str, instead of unicode.
[G:\temp]type tests.py
import __future__
import ast
# code object
c = compile("s='hello'; print s,type(s)",
"<unknown>", mode="exec",
flags=__future__.unicode_literals.compiler_flag)
exec c
# ast
a = compile("'hello'",
"<unknown>", mode="eval",
flags=ast.PyCF_ONLY_AST | __future__.unicode_literals.compiler_flag)
print a.body.s, type(a.body.s)
[G:\temp]python tests.py
hello <type 'unicode'>
hello <type 'unicode'>
[G:\temp]d:\TOOLS\jython-repo\dist\bin\jython.bat tests.py
hello <type 'str'>
hello <type 'str'>
The last 2 should be 'unicode' as well. Doing from __future__ import unicode_literals, which works for normal python modules, doesn't help for the compile() function. |
|
Date |
User |
Action |
Args |
2013-01-19 15:09:37 | irmen | set | recipients:
+ irmen |
2013-01-19 15:09:37 | irmen | set | messageid: <1358608177.34.0.246873717165.issue2008@psf.upfronthosting.co.za> |
2013-01-19 15:09:37 | irmen | link | issue2008 messages |
2013-01-19 15:09:37 | irmen | create | |
|