[Python-bugs-list] [ python-Bugs-595018 ] inspect.getsource shows incorrect output

noreply@sourceforge.net noreply@sourceforge.net
Wed, 14 Aug 2002 04:41:26 -0700


Bugs item #595018, was opened at 2002-08-14 13:41
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=595018&group_id=5470

Category: Python Library
Group: Python 2.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Gregor Lingl (glingl)
Assigned to: Nobody/Anonymous (nobody)
Summary: inspect.getsource shows incorrect output

Initial Comment:
example:
>>> from turtle import *
>>> from inspect import *
>>> print getsource(up)
def up(): _getpen().up()
def down(): _getpen().down()
def width(width): _getpen().width(width)
def color(*args): apply(_getpen().color, args)
def write(arg, move=0): _getpen().write(arg, move)
def fill(flag): _getpen().fill(flag)
def circle(radius, extent=None):
_getpen().circle(radius, extent)
def goto(*args): apply(_getpen().goto, args)

def demo():
    reset()
    tracer(1)
# etc ...

changing the form of the definition of up in turtle to:

def up(): 
     _getpen().up()

results in:

>>> print getsource(up)
def up():
     _getpen().up()

>>> 

So the error probably occurs when parsing the
sourcefile if functiondefinition is a oneliner ...

Regards
Gregor Lingl


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

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