Message74358
| Author |
brodie |
| Recipients |
brodie |
| Date |
2008年10月06日.03:20:43 |
| SpamBayes Score |
2.7957636e-12 |
| Marked as misclassified |
No |
| Message-id |
<1223263246.04.0.311292342093.issue4050@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Calling inspect.findsource() on a module whose __file__ attribute points
to a shared library causes findsource() to return the binary's data:
>>> import time
>>> time.__file__
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
lib-dynload/time.so'
>>> import inspect
>>> inspect.findsource(time)
(['\xca\xfe\xba\xbe\x00\x00\x00\x04\x00\x00\x00\x12\x00\x00\x00\n',
'\x00\x00\x10\x00\x00\x00Jt\x00...
It should raise an error saying it can't retrieve the source. It doesn't
do this because when it tries to find the source file it calls both
getsourcefile() - and getfile() when that fails. It should call only
getsourcefile() - which checks to see if __file__ points to a binary -
and if the result is None, raise an error.
I'm attaching a patch against trunk that fixes this. The issue affects
3.0, 2.6, 2.5, and probably previous versions. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2008年10月06日 03:20:46 | brodie | set | recipients:
+ brodie |
| 2008年10月06日 03:20:46 | brodie | set | messageid: <1223263246.04.0.311292342093.issue4050@psf.upfronthosting.co.za> |
| 2008年10月06日 03:20:45 | brodie | link | issue4050 messages |
| 2008年10月06日 03:20:44 | brodie | create |
|