[pypy-svn] r31372 - in pypy/dist/pypy: objspace/cpy/test rpython
pedronis at codespeak.net
pedronis at codespeak.net
Thu Aug 17 16:33:11 CEST 2006
Author: pedronis
Date: Thu Aug 17 16:33:09 2006
New Revision: 31372
Modified:
pypy/dist/pypy/objspace/cpy/test/test_typedef.py
pypy/dist/pypy/rpython/rcpy.py
Log:
(arre, pedronis)
use a __new__ in ext-compiled types if it is there
Modified: pypy/dist/pypy/objspace/cpy/test/test_typedef.py
==============================================================================
--- pypy/dist/pypy/objspace/cpy/test/test_typedef.py (original)
+++ pypy/dist/pypy/objspace/cpy/test/test_typedef.py Thu Aug 17 16:33:09 2006
@@ -273,7 +273,8 @@
mytype_new.unwrap_spec = [ObjSpace, W_Root, int]
W_MyType.typedef = TypeDef("MyType",
- __new__ = interp2app(mytype_new))
+ __new__ = interp2app(mytype_new),
+ x = interp_attrproperty("x", W_MyType))
space = CPyObjSpace()
def build():
@@ -283,11 +284,13 @@
w_obj = build()
w_name = space.getattr(space.type(w_obj), space.wrap('__name__'))
assert space.unwrap(w_name) == 'MyType'
+ assert space.int_w(space.getattr(w_obj, space.wrap('x'))) == 42
fn = compile(build, [],
annotatorpolicy = CPyAnnotatorPolicy(space))
res = fn(expected_extra_mallocs=1)
assert type(res).__name__ == 'MyType'
+ assert res.x == 42
def test_prebuilt_type():
def mytype_new(space, w_subtype, x):
Modified: pypy/dist/pypy/rpython/rcpy.py
==============================================================================
--- pypy/dist/pypy/rpython/rcpy.py (original)
+++ pypy/dist/pypy/rpython/rcpy.py Thu Aug 17 16:33:09 2006
@@ -258,6 +258,10 @@
if cpytype.objects:
objects = [(lltype.pyobjectptr(name), value)
for name, value in cpytype.objects.items() if name != '__new__']
+ if '__new__' in cpytype.objects:
+ new = cpytype.objects['__new__']._obj.value
+ objects.append((lltype.pyobjectptr('__new__'),
+ lltype.pyobjectptr(staticmethod(new))))
def ll_type_setup(p):
tp = lltype.cast_pointer(lltype.Ptr(PY_TYPE_OBJECT), p)
More information about the Pypy-commit
mailing list