New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unicode_literals doesn't work in exec #48475
Comments
exec "from __future__ import unicode_literals; print type('')" gives <type 'str'> in 2.6/2.7. It's the result of flags not being passed |
The attached patch works, but can be simplified by using a stack variable: Index: pythonrun.c {
PyObject *ret = NULL;
mod_ty mod;
- PyArena *arena = PyArena_New();
+ PyCompilerFlags localflags;
+ PyArena *arena;
+
+ if (flags == NULL)
+ flags = &localflags;
+
+ arena = PyArena_New();
if (arena == NULL)
return NULL; |
This patch uses heap variables and tries to catch more places. |
The newer patch is good. I found another use of PyAST_FromNode() with NULL flags, and which has import parser
s=parser.suite(
"from __future__ import unicode_literals; print type('')")
eval(s.compile()) But I don't know how to correct this: the CO_FUTURE_UNICODE_LITERALS |
Here's a patch that handles the parser module. |
The patch is good, |
The removal of the "static" was a mistake. Fixed in r67066. |
This problem will still persist for anybody who uses PyParser_* APIs and |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: