[issue12920] Document that inspect.getsource only works for objects loaded from files, not interactive session

2015-06-23 Thread Ned Deily

Ned Deily added the comment:

In duplicate Issue24491, zorceta notes: "Both python.exe and IDLE can't. 
IPython is able to, as it inserts REPL input into linecache."

--
nosy: +ned.deily, zorceta
versions: +Python 3.5, Python 3.6 -Python 3.2, Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12920] Document that inspect.getsource only works for objects loaded from files, not interactive session

2013-03-24 Thread Éric Araujo

É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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com