Patches item #1692664, was opened at 2007-04-01 23:23
Message generated for change (Comment added) made by rhamphoryncus
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.

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

>Comment By: Adam Olsen (rhamphoryncus)
Date: 2007-04-03 01:00

Message:
Logged In: YES 
user_id=12364
Originator: YES

The test_stackoverflow_message test I added causes warnings.py to use
sys.__warningregistry__ rather than test_warnings.__warningregistry__. 
This circumvents this self-declared hack of deleting
test_warnings.__warningregistry__ to allow regrtest -R to run.

This version of the patch uses a more general solution to allowing
regrtest -R to run.  Probably doesn't qualify as a hack anymore...
File Added: python2.6-warningfilename2.diff

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

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