[pypy-svn] r14545 - in pypy/dist/pypy/rpython: . test
pedronis at codespeak.net
pedronis at codespeak.net
Tue Jul 12 16:00:53 CEST 2005
Author: pedronis
Date: Tue Jul 12 16:00:51 2005
New Revision: 14545
Modified:
pypy/dist/pypy/rpython/normalizecalls.py
pypy/dist/pypy/rpython/test/test_rpbc.py
Log:
fixes & test
Modified: pypy/dist/pypy/rpython/normalizecalls.py
==============================================================================
--- pypy/dist/pypy/rpython/normalizecalls.py (original)
+++ pypy/dist/pypy/rpython/normalizecalls.py Tue Jul 12 16:00:51 2005
@@ -4,7 +4,7 @@
from pypy.objspace.flow.model import Variable, Constant, Block, Link
from pypy.objspace.flow.model import SpaceOperation, checkgraph
from pypy.annotation import model as annmodel
-from pypy.tool.sourcetools import has_varargs
+from pypy.tool.sourcetools import has_varargs, valid_identifier
from pypy.rpython.rmodel import TyperError
@@ -237,6 +237,8 @@
raise TyperError("calls to mixed class/non-class objects in the "
"family %r" % family.objects.keys())
+ patterns = family.patterns.copy()
+
klasses = [klass for (_, klass) in family.objects.keys()]
functions = {}
function_values = {}
@@ -266,16 +268,17 @@
args2.pop(0) # 'self'
funcsig = ', '.join(args)
callsig = ', '.join(args2)
+ klass_name = valid_identifier(klass.__name__)
source = py.code.Source('''
def %s__new__(%s):
return ____class(%s)
''' % (
- klass.__name__, funcsig, callsig))
+ klass_name, funcsig, callsig))
miniglobals = {
'____class': klass,
}
exec source.compile() in miniglobals
- klass__new__ = miniglobals['%s__new__' % klass.__name__]
+ klass__new__ = miniglobals['%s__new__' % klass_name]
if initfunc:
klass__new__.func_defaults = initfunc.func_defaults
graph = rtyper.annotator.translator.getflowgraph(initfunc)
@@ -304,7 +307,7 @@
for klass__new__ in functionslist[1:]:
_, _, new_call_family = call_families.union(key0,
(None, klass__new__))
- new_call_family.patterns = family.patterns
+ new_call_family.patterns = patterns
def perform_normalizations(rtyper):
Modified: pypy/dist/pypy/rpython/test/test_rpbc.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rpbc.py (original)
+++ pypy/dist/pypy/rpython/test/test_rpbc.py Tue Jul 12 16:00:51 2005
@@ -337,14 +337,14 @@
res = interpret(f, [1])
assert res.super.typeptr.name[0] == 'B'
-def test_call_classes_with_init():
+def test_call_classes_with_init2():
class A:
def __init__(self, z):
self.z = z
class B(A):
- def __init__(self, z):
+ def __init__(self, z, x=42):
A.__init__(self, z)
- self.extra = 42
+ self.extra = x
def f(i, z):
if i == 1:
cls = B
@@ -358,3 +358,4 @@
assert res.super.typeptr.name[0] == 'B'
assert res.inst_z == -7645
assert res._obj._parentstructure().inst_extra == 42
+
More information about the Pypy-commit
mailing list