[pypy-svn] r9918 - in pypy/dist/pypy: interpreter objspace/std

arigo at codespeak.net arigo at codespeak.net
Sun Mar 20 15:51:53 CET 2005


Author: arigo
Date: Sun Mar 20 15:51:53 2005
New Revision: 9918

Modified:
   pypy/dist/pypy/interpreter/typedef.py
   pypy/dist/pypy/objspace/std/booltype.py
   pypy/dist/pypy/objspace/std/typeobject.py
Log:
Prevent 'bool' from being subclassed.


Modified: pypy/dist/pypy/interpreter/typedef.py
==============================================================================
--- pypy/dist/pypy/interpreter/typedef.py	(original)
+++ pypy/dist/pypy/interpreter/typedef.py	Sun Mar 20 15:51:53 2005
@@ -16,6 +16,7 @@
         self.base = __base
         self.hasdict = '__dict__' in rawdict or (__base and __base.hasdict)
         self.rawdict = rawdict
+        self.acceptable_as_base_class = True
 
 
 unique_interplevel_subclass_cache = Cache()

Modified: pypy/dist/pypy/objspace/std/booltype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/booltype.py	(original)
+++ pypy/dist/pypy/objspace/std/booltype.py	Sun Mar 20 15:51:53 2005
@@ -15,3 +15,4 @@
 bool_typedef = StdTypeDef("bool", int_typedef,
     __new__ = newmethod(descr__new__),
     )
+bool_typedef.acceptable_as_base_class = False

Modified: pypy/dist/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/typeobject.py	(original)
+++ pypy/dist/pypy/objspace/std/typeobject.py	Sun Mar 20 15:51:53 2005
@@ -34,6 +34,11 @@
                     raise OperationError(space.w_TypeError,
                                 space.wrap("instance layout conflicts in "
                                                     "multiple inheritance"))
+            if not instancetypedef.acceptable_as_base_class:
+                raise OperationError(space.w_TypeError,
+                                     space.wrap("type '%s' is not an "
+                                                "acceptable base class" %
+                                                instancetypedef.name))
             w_self.instancetypedef = instancetypedef
             w_self.hasdict = False
             hasoldstylebase = False



More information about the Pypy-commit mailing list