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.

Author Rhamphoryncus
Recipients
Date 2007-04-02.05:23:18
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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.
History
Date User Action Args
2007-08-23 15:57:52adminlinkissue1692664 messages
2007-08-23 15:57:52admincreate