Message79159
| Author |
exarkun |
| Recipients |
exarkun |
| Date |
2009年01月05日.16:00:37 |
| SpamBayes Score |
0.004606073 |
| Marked as misclassified |
No |
| Message-id |
<1231171240.01.0.534546346997.issue4845@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Here's a transcript demonstrating the disagreement:
exarkun@charm:~$ mkdir warningexample
exarkun@charm:~$ cd warningexample/
exarkun@charm:~/warningexample$ mkdir foo
exarkun@charm:~/warningexample$ touch foo/__init__.py
exarkun@charm:~/warningexample$ cat > foo/bar.py
import warnings
def foo():
warnings.warn("foo")
exarkun@charm:~/warningexample$ python -c 'import foo.bar'
exarkun@charm:~/warningexample$ mv foo bar
exarkun@charm:~/warningexample$ python -c 'import bar.bar; bar.bar.foo()'
bar/bar.py:3: UserWarning: foo
warnings.warn("foo")
exarkun@charm:~/warningexample$ python -c 'import bar.bar, inspect;
print inspect.getabsfile(bar.bar.foo)'
/home/exarkun/warningexample/foo/bar.py
exarkun@charm:~/warningexample$
Notice that the warning is emitted for the file bar/bar.py but the
inspect module claims that the function which emitted the warning is
defined in /home/exarkun/warningexample/foo/bar.py. It seems that the
warning system has somehow noticed that the .pyc file has the wrong
source file listed and has figured out the correct file name, whereas
the inspect module is blindly following the contents of the .pyc file.
It would be great if the inspect module were at least as good at
figuring out filenames as the warnings system. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2009年01月05日 16:00:40 | exarkun | set | recipients:
+ exarkun |
| 2009年01月05日 16:00:40 | exarkun | set | messageid: <1231171240.01.0.534546346997.issue4845@psf.upfronthosting.co.za> |
| 2009年01月05日 16:00:39 | exarkun | link | issue4845 messages |
| 2009年01月05日 16:00:37 | exarkun | create |
|