[Python-bugs-list] [ python-Bugs-620190 ] inspect and object instances
SourceForge.net
noreply@sourceforge.net
Thu, 19 Jun 2003 10:26:16 -0700
Bugs item #620190, was opened at 2002-10-08 12:26
Message generated for change (Settings changed) made by jhylton
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=620190&group_id=5470
Category: Python Library
Group: Python 2.2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Alexander Schmolck (aschmolck)
>Assigned to: Jeremy Hylton (jhylton)
Summary: inspect and object instances
Initial Comment:
inspect.getargspec(NewKlass.aMethod) fails (which
might technically be OK because the docs only mention
functions, not methods) but I also vaguely seem to
remember that some other operations in the inspect
module only worked for oldstyle classes under 2.2.1.
----------------------------------------------------------------------
Comment By: Michael Stone (mbrierst)
Date: 2003-02-11 22:46
Message:
Logged In: YES
user_id=670441
Well I think this (one line)
patch will make getargspec work with
methods, if anyone wants to apply it.
Did you find any other operations that
don't work?
patch:
Index: Lib/inspect.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v
retrieving revision 1.41
diff -c -r1.41 inspect.py
*** Lib/inspect.py 19 Jan 2003 13:21:20 -0000 1.41
--- Lib/inspect.py 11 Feb 2003 22:35:41 -0000
***************
*** 16,22 ****
getmodule() - determine the module that an object came from
getclasstree() - arrange classes so as to represent their hierarchy
! getargspec(), getargvalues() - get info about function arguments
formatargspec(), formatargvalues() - format an argument spec
getouterframes(), getinnerframes() - get info about frames
currentframe() - get the current stack frame
--- 16,22 ----
getmodule() - determine the module that an object came from
getclasstree() - arrange classes so as to represent their hierarchy
! getargspec(), getargvalues() - get info about function or method's arguments
formatargspec(), formatargvalues() - format an argument spec
getouterframes(), getinnerframes() - get info about frames
currentframe() - get the current stack frame
***************
*** 625,636 ****
return args, varargs, varkw
def getargspec(func):
! """Get the names and default values of a function's arguments.
A tuple of four things is returned: (args, varargs, varkw, defaults).
'args' is a list of the argument names (it may contain nested lists).
'varargs' and 'varkw' are the names of the * and ** arguments or None.
'defaults' is an n-tuple of the default values of the last n arguments."""
if not isfunction(func): raise TypeError, 'arg is not a Python function'
args, varargs, varkw = getargs(func.func_code)
return args, varargs, varkw, func.func_defaults
--- 625,637 ----
return args, varargs, varkw
def getargspec(func):
! """Get the names and default values of a function or method's arguments.
A tuple of four things is returned: (args, varargs, varkw, defaults).
'args' is a list of the argument names (it may contain nested lists).
'varargs' and 'varkw' are the names of the * and ** arguments or None.
'defaults' is an n-tuple of the default values of the last n arguments."""
+ if ismethod(func): func = func.im_func
if not isfunction(func): raise TypeError, 'arg is not a Python function'
args, varargs, varkw = getargs(func.func_code)
return args, varargs, varkw, func.func_defaults
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=620190&group_id=5470