Message207736
Following situation
* python 2.7.6
* module loaded via a PEP302 loader.
* the loader has get_source(fullname)
* assigns a dummy string as a file: module.__file__ == "<mymodule>"
Then
inspect.getsource(module)
throws
IOError: could not get source code
I tired to track this down, and it seems to be caused by linecache.updatecache(..) with has
if not filename or (filename.startswith('<') and filename.endswith('>')):
return []
at the beginning.
This seems too restrictive me. Without the 'if' it would try to read the file from disk, and if that fails check if there is a loader, without a loader it returns [], so there would not be any behaviour change for non-loader modules if the 'if' was removed, only an additional disk access.
I suggest to remove the 'if'.
Workaround: Don't use '<>' for the dummy file name, but I've read somewhere that those '<>' are a convention for such use-cases. |
|
Date |
User |
Action |
Args |
2014-01-09 13:18:49 | stefan.mueller | set | recipients:
+ stefan.mueller |
2014-01-09 13:18:49 | stefan.mueller | set | messageid: <1389273529.73.0.188399599981.issue20205@psf.upfronthosting.co.za> |
2014-01-09 13:18:49 | stefan.mueller | link | issue20205 messages |
2014-01-09 13:18:49 | stefan.mueller | create | |
|