[issue3423] DeprecationWarning message applies to wrong context with exec()
Zachary Ware
report at bugs.python.org
Mon Jun 23 03:30:00 CEST 2014
Zachary Ware added the comment:
Sorry, Terry; I updated the resolution because the issue was not closed, and the versions to match the currently acceptable branches after a discussion at the Bloomberg sprint, but failed to elaborate on what the actual bug here is that came out of that discussion.
The actual problem is with any warning raised by exec'ing a string:
C:\Temp>type exectest.py
# line 1
import os
os.listdir(b'.') # line 5
exec("os.listdir(b'.')") # line 7
C:\Temp>py -3.4 -Wall exectest.py
exectest.py:5: DeprecationWarning: The Windows bytes API has been deprecated, use Unicode filenames instead
os.listdir(b'.') # line 5
exectest.py:1: DeprecationWarning: The Windows bytes API has been deprecated, use Unicode filenames instead
# line 1
C:\Temp>type exectest-2.7.py
# line 1
"test" > 3 # line 3
exec("'test' > 3") # line 5
C:\Temp>py -2.7 -3 -Wall exectest-2.7.py
exectest-2.7.py:3: DeprecationWarning: comparing unequal types not supported in 3.x
"test" > 3 # line 3
exectest-2.7.py:1: DeprecationWarning: comparing unequal types not supported in 3.x
# line 1
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3423>
_______________________________________
More information about the Python-bugs-list
mailing list