Issue2008

classification
Title: compile() doesn't pay attention to unicode_literals flag
Type: behaviour Severity: major
Components: Core Versions: Jython 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, irmen, zyasoft
Priority: normal Keywords:

Created on 2013-01-19.15:09:37 by irmen, last changed 2014-06-19.06:27:23 by zyasoft.

Messages
msg7581 (view) Author: Irmen de Jong (irmen) Date: 2013-01-19.15:09:37
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.
msg8727 (view) Author: Jim Baker (zyasoft) Date: 2014-06-19.06:27:23
Likely the same underlying bug seen in #2039

Target beta 4, this is important
History
Date User Action Args
2014-06-19 06:27:23zyasoftsetnosy: + zyasoft
messages: + msg8727
2013-02-20 00:24:25fwierzbickisetpriority: normal
nosy: + fwierzbicki
versions: + Jython 2.7, - 2.7a2
2013-01-19 15:09:37irmencreate