[pypy-commit] pypy default: Convert this code to support Python 2.5.
arigo
noreply at buildbot.pypy.org
Thu Jul 26 09:49:24 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r56454:becc765d003e
Date: 2012-07-26 09:40 +0200
http://bitbucket.org/pypy/pypy/changeset/becc765d003e/
Log: Convert this code to support Python 2.5.
diff --git a/pypy/rlib/objectmodel.py b/pypy/rlib/objectmodel.py
--- a/pypy/rlib/objectmodel.py
+++ b/pypy/rlib/objectmodel.py
@@ -146,20 +146,20 @@
# we cannot simply wrap the function using *args, **kwds, because it's
# not RPython. Instead, we generate a function with exactly the same
# argument list
- argspec = inspect.getargspec(f)
- assert len(argspec.args) == len(types), (
+ srcargs, srcvarargs, srckeywords, defaults = inspect.getargspec(f)
+ assert len(srcargs) == len(types), (
'not enough types provided: expected %d, got %d' %
- (len(types), len(argspec.args)))
- assert not argspec.varargs, '*args not supported by enforceargs'
- assert not argspec.keywords, '**kwargs not supported by enforceargs'
+ (len(types), len(srcargs)))
+ assert not srcvarargs, '*args not supported by enforceargs'
+ assert not srckeywords, '**kwargs not supported by enforceargs'
#
- arglist = ', '.join(argspec.args)
+ arglist = ', '.join(srcargs)
src = py.code.Source("""
- def {name}({arglist}):
+ def %(name)s(%(arglist)s):
if not we_are_translated():
- typecheck({arglist})
- return {name}_original({arglist})
- """.format(name=f.func_name, arglist=arglist))
+ typecheck(%(arglist)s)
+ return %(name)s_original(%(arglist)s)
+ """ % dict(name=f.func_name, arglist=arglist))
#
mydict = {f.func_name + '_original': f,
'typecheck': typecheck,
More information about the pypy-commit
mailing list