[Python-Dev] Add new PyErr_WarnEx() to 2.5? (original) (raw)

Tim Peters tim.peters at gmail.com
Mon Jul 10 20:23:11 CEST 2006


As noted in

http://mail.python.org/pipermail/python-dev/2006-May/065478.html

it looks like we need a new Python C API function to make new warnings from the struct module non-useless. For example, runnning test_zipfile on Windows now yields

""" test_zipfile C:\Code\python\lib\struct.py:63: DeprecationWarning: struct integer overflow masking is deprecated return o.pack(*args) """

This is useless because the message points into struct.py, not to the code calling struct.pack(). Consequently I have no idea where the offending pack() call is, and neither do you ;-)

The current PyErr_Warn() doesn't allow for passing a non-zero stacklevel argument to warnings.warn(), so there's little the C code in _struct.c can do to make the warning more useful.



More information about the Python-Dev mailing list