This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix module output for warnings from the interpreter
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: brett.cannon
Priority: critical Keywords:

Created on 2008-05-02 21:26 by brett.cannon, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg66112 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-05-02 21:26
In svn, the module name is lost if you raise an exception at the 
interpreter::

 >>> import warnings
 >>> warnings.warn("foo")
 :1: UserWarning: foo

It should be::

 >>> import warnings
 >>> warnings.warn("foo")
 __main__:1: UserWarning: foo

Notice how '__main__' is missing in svn.
msg66138 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-05-03 01:34
So I found the problem. The C implementation of 'warnings' is not handling 
the case where the module that triggered the exception does not define 
__file__, __name__ == '__main__', and sys.argv[0] is a false value in the 
same way as the Python implementation.

Rather obscure to say the least. =)
msg66141 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-05-03 03:21
r62656 has the fix.
History
Date User Action Args
2022-04-11 14:56:33adminsetgithub: 46992
2008-05-03 03:21:41brett.cannonsetstatus: open -> closed
resolution: fixed
messages: + msg66141
2008-05-03 01:35:00brett.cannonsetmessages: + msg66138
2008-05-02 21:26:48brett.cannoncreate