Patches item #1692664, was opened at 2007-04-01 23:23
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1692664&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Adam Olsen (rhamphoryncus)
Assigned to: Nobody/Anonymous (nobody)
Summary: warnings.py gets filename wrong for eval/exec

Initial Comment:
warnings.warn() gets the filename using the globals' __file__ attribute.  When 
using eval or exec this is often not the context in which the current line was 
compiled from.  The line number is correct, but will be applied to whatever 
file the globals are from, leading to an unrelated line being printed below the 
warning.

The attached patch makes it use caller.f_code.co_filename instead.  This also 
seems to remove the need to normalize .pyc/.pyo files, as well as not needing 
to use sys.argv[0] for __main__ modules.

It also cleans up warnings.warn() and adds three unit tests.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1692664&group_id=5470
_______________________________________________
Patches mailing list
[email protected]
http://mail.python.org/mailman/listinfo/patches

Reply via email to