[issue3423] DeprecationWarning message applies to wrong context with exec()

Terry J. Reedy report at bugs.python.org
Thu Jun 10 01:42:38 CEST 2010


Terry J. Reedy <tjreedy at udel.edu> added the comment:

In 3.1, I get
>>> exec("1/0")
Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    exec("1/0")
  File "<string>", line 1, in <module>
ZeroDivisionError: int division or modulo by zero

In your example, would you really prefer that the warning message start with "<string>1" (or the 2.x equivalent) instead of "t.py1"? If I were running a multi-file app with warnings turned on, I would prefer the latter. The message "DeprecationWarning: raising a string exception is deprecated" is certainly enough to suggest that one search the file for 'raise'.

In any case, this would only be a bug if it disagreed with docs or if this were different from the usual behavior with deprecation warnings. It is too late for new features in 2.x and this does not apply to 3.x.

----------
nosy: +tjreedy
resolution:  -> rejected
status: open -> closed
type:  -> feature request

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


More information about the Python-bugs-list mailing list