[Python-bugs-list] [ python-Bugs-661184 ] inspect.getsource bug

noreply@sourceforge.net noreply@sourceforge.net
Thu, 02 Jan 2003 09:08:12 -0800


Bugs item #661184, was opened at 2003-01-02 12:08
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=661184&group_id=5470

Category: Python Library
Group: Python 2.2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Michele Simionato (michele_s)
Assigned to: Nobody/Anonymous (nobody)
Summary: inspect.getsource bug

Initial Comment:
I have found a bug in inspect.getsource.
I am using Python 2.2.2 on Red-Hat 7.3. 
Here is the problem.

--begin bug.py

import inspect
def f(x): return x
print inspect.getsource(f)

--end bug.py

% python bug.py
Traceback (most recent call last):
  File "bug.py", line 3, in ?
    print inspect.getsource(f)
  File "/usr/local/lib/python2.2/inspect.py", line 520,
in getsource
    return string.join(lines, '')
  File "/usr/local/lib/python2.2/string.py", line 131,
in join
    return sep.join(words)
TypeError: sequence expected, NoneType found

Notice that
 
--begin noproblem.py

import inspect
def f(x): 
    return x
print inspect.getsource(f)

--end noproblem.py

works:

% python noproblem.py
def f(x):
    return x

I discovered this bug in trying to retrieve the source
code for lambda expressions: 

--begin lambda.py

import inspect
f=lambda x: x
print inspect.getsource(f) 

--begin lambda.py

(same error message).


--
Michele Simionato - Dept. of Physics and Astronomy
210 Allen Hall Pittsburgh PA 15260 U.S.A.
Phone: 001-412-624-9041 Fax: 001-412-624-9163
Home-page: http://www.phyast.pitt.edu/~micheles/




----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=661184&group_id=5470