Commit 50d735fc authored by Kevin Modzelewski's avatar Kevin Modzelewski

Update inspect to better match how we represent builtin functions

parent 42218c87
......@@ -818,6 +818,11 @@ def getargspec(func):
func = func.im_func
if not isfunction(func):
raise TypeError('{!r} is not a Python function'.format(func))
# Pyston change: many of our builtin functions are of type FunctionType, but
# don't have full introspection available. I think this check catches most of them,
# though I think it allows some cases that CPython does not:
if func.func_code.co_argcount > len(func.func_code.co_varnames):
raise TypeError('{!r} is not a Python function'.format(func))
args, varargs, varkw = getargs(func.func_code)
return ArgSpec(args, varargs, varkw, func.func_defaults)
......
......@@ -5,8 +5,21 @@ def f1(a, b=2, *args, **kw):
def f2():
pass
class C(object):
def __init__(self):
pass
class D(object):
pass
print inspect.getargspec(f1)
print inspect.getargspec(f2)
print inspect.getargspec(C.__init__)
print inspect.getargspec(C().__init__)
try:
print inspect.getargspec(D.__init__)
except Exception as e:
print type(e)
def G():
yield 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment