É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 <rep...@bugs.python.org>
<http://bugs.python.org/issue12920>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to