[docs] [issue16355] inspect.getcomments() does not work in the interactive shell

Marco Buttu report at bugs.python.org
Mon Oct 29 16:19:17 CET 2012

Marco Buttu added the comment:

I saw there is the same lack of clarity in the doc of `inspect.getsource()`:

>>> import inspect
>>> print(inspect.getsource.__doc__)
Return the text of the source code for an object.

    The argument may be a module, class, method, function, traceback, frame,
    or code object.  The source code is returned as a single string.  An
    IOError is raised if the source code cannot be retrieved.
>>> def foo():
...     pass
>>> inspect.getsource(foo)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.3/inspect.py", line 726, in getsource
    lines, lnum = getsourcelines(object)
  File "/usr/local/lib/python3.3/inspect.py", line 715, in getsourcelines
    lines, lnum = findsource(object)
  File "/usr/local/lib/python3.3/inspect.py", line 563, in findsource
    raise IOError('could not get source code')
OSError: could not get source code


Python tracker <report at bugs.python.org>

More information about the docs mailing list