Message52364
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. |
|
Date |
User |
Action |
Args |
2007-08-23 15:57:52 | admin | link | issue1692664 messages |
2007-08-23 15:57:52 | admin | create | |
|