[pypy-svn] r12349 - in pypy/dist/pypy/objspace/std: . test
pedronis at codespeak.net
pedronis at codespeak.net
Mon May 16 14:04:45 CEST 2005
Author: pedronis
Date: Mon May 16 14:04:45 2005
New Revision: 12349
Modified:
pypy/dist/pypy/objspace/std/objecttype.py
pypy/dist/pypy/objspace/std/test/test_typeobject.py
Log:
explicitly disallow type('I',(int,), {'__slots__': ()})().__class__ = int
Modified: pypy/dist/pypy/objspace/std/objecttype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objecttype.py (original)
+++ pypy/dist/pypy/objspace/std/objecttype.py Mon May 16 14:04:45 2005
@@ -22,6 +22,9 @@
raise OperationError(space.w_TypeError,
space.wrap("__class__ must be set to new-style class, not '%s' object" %
space.type(w_newcls).getname(space, '?')))
+ if not w_newcls.is_heaptype():
+ raise OperationError(space.w_TypeError,
+ space.wrap("__class__ assignment: only for heap types"))
w_oldcls = space.type(w_obj)
if w_oldcls.get_layout() == w_newcls.get_layout() and w_oldcls.hasdict == w_newcls.hasdict:
w_obj.setclass(space, w_newcls)
Modified: pypy/dist/pypy/objspace/std/test/test_typeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_typeobject.py (original)
+++ pypy/dist/pypy/objspace/std/test/test_typeobject.py Mon May 16 14:04:45 2005
@@ -406,6 +406,7 @@
pass
i = I()
+
i2 = I()
i.__class__ = I2
i2.__class__ = I
@@ -429,6 +430,10 @@
raises(TypeError, "X().__class__ = object")
raises(TypeError, "X().__class__ = 1")
+ class Int(int): __slots__ = []
+
+ raises(TypeError, "Int().__class__ = int")
+
def test_name(self):
class Abc(object):
pass
More information about the Pypy-commit
mailing list