[pypy-svn] r36409 - in pypy/dist/pypy/objspace/std: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Wed Jan 10 16:16:18 CET 2007
Author: cfbolz
Date: Wed Jan 10 16:16:17 2007
New Revision: 36409
Modified:
pypy/dist/pypy/objspace/std/test/test_versionedtype.py
pypy/dist/pypy/objspace/std/typeobject.py
Log:
(pedronis, cfbolz): also do the right thing when you subclass such types.
Modified: pypy/dist/pypy/objspace/std/test/test_versionedtype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_versionedtype.py (original)
+++ pypy/dist/pypy/objspace/std/test/test_versionedtype.py Wed Jan 10 16:16:17 2007
@@ -77,6 +77,33 @@
""")
assert w_function.version_tag is None
+ def test_version_tag_of_subclasses_of_builtin_types(self):
+ space = self.space
+ w_types = space.appexec([], """():
+ import sys
+ class LIST(list):
+ def f(self): pass
+ class DICT(dict):
+ pass
+ class TYPE(type):
+ pass
+ class MODULE(type(sys)):
+ pass
+ def f(x): pass
+ class FUNCTION(type(f)):
+ pass
+ class OBJECT(object):
+ pass
+ return [LIST, DICT, TYPE, MODULE, FUNCTION, OBJECT]
+ """)
+ (w_LIST, w_DICT, w_TYPE, w_MODULE, w_FUNCTION,
+ w_OBJECT) = space.unpackiterable(w_types)
+ assert w_LIST.version_tag is not None
+ assert w_DICT.version_tag is not None
+ assert w_TYPE.version_tag is None
+ assert w_MODULE.version_tag is None
+ assert w_FUNCTION.version_tag is None
+ assert w_OBJECT.version_tag is not None
class AppTestVersionedType(test_typeobject.AppTestTypeObject):
def setup_class(cls):
Modified: pypy/dist/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/typeobject.py (original)
+++ pypy/dist/pypy/objspace/std/typeobject.py Wed Jan 10 16:16:17 2007
@@ -213,7 +213,7 @@
return
w_self.mro_w = w_self.compute_mro()
if space.config.objspace.std.withtypeversion:
- if overridetypedef is not None and w_self.hasdict:
+ if w_self.instancetypedef.hasdict:
w_self.version_tag = None
else:
w_self.version_tag = VersionTag()
More information about the Pypy-commit
mailing list