[docs] [issue12920] Document that inspect.getsource only works for objects loaded from files, not interactive session
Éric Araujo
report at bugs.python.org
Mon Mar 25 03:54:47 CET 2013
Éric Araujo added the comment:
> It seems to work perfectly on command line though.
If the code is saved in a file, yes, but not in an interactive interpreter. This is not actually related to IDLE, but to the fact that inspect.getsource merely finds the __file__ attribute of the module object for its argument. If a module object has no file, the error message indicates that it’s a built-in module (like sys), but this fails to take into account the special __main__ module in an interactive interpreter.
It might be worth it to improve the error message, and in any case the documentation can be improved.
----------
stage: -> needs patch
title: inspect.getsource fails to get source of local classes -> Document that inspect.getsource only works for objects loaded from files, not interactive session
versions: +Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12920>
_______________________________________
More information about the docs
mailing list