Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r84089:2d9f54097bd9
Date: 2016-05-01 11:15 +0200
http://bitbucket.org/pypy/pypy/changeset/2d9f54097bd9/

Log:    Backed out changeset 1cb2c3897dbb

        It makes a single RPython subclass instead of two if the base
        RPython class has already got a __del__. But this base __del__ might
        be lightweight; then the RPython subclass will always have a
        heavyweight finalizer...

diff --git a/pypy/interpreter/test/test_typedef.py 
b/pypy/interpreter/test/test_typedef.py
--- a/pypy/interpreter/test/test_typedef.py
+++ b/pypy/interpreter/test/test_typedef.py
@@ -383,25 +383,6 @@
         assert not hasattr(b, "storage")
         assert hasattr(c, "storage")
 
-    def test_del(self):
-        space = self.space
-        a, b, c, d = space.unpackiterable(space.appexec([], """():
-            class A(object):
-                pass
-            class B(object):
-                def __del__(self):
-                    pass
-            class F(file):
-                pass
-            class G(file):
-                def __del__(self):
-                    pass
-            return A(), B(), F("xyz", "w"), G("ghi", "w")
-        """))
-        assert type(b).__base__ is type(a)
-        assert hasattr(c, "__del__")
-        assert type(d) is type(c)
-
 class AppTestTypeDef:
 
     def setup_class(cls):
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -113,18 +113,11 @@
         return _subclass_cache[key]
     except KeyError:
         # XXX can save a class if cls already has a __del__
-        keys = [key]
-        base_has_del = hasattr(cls, '__del__')
-        if base_has_del:
-            # if the base has a __del__, we only need one class
-            keys = [(space, cls, True), (space, cls, False)]
-            needsdel = True
-        elif needsdel:
+        if needsdel:
             cls = get_unique_interplevel_subclass(space, cls, False)
         subcls = _getusercls(space, cls, needsdel)
         assert key not in _subclass_cache
-        for key in keys:
-            _subclass_cache[key] = subcls
+        _subclass_cache[key] = subcls
         return subcls
 get_unique_interplevel_subclass._annspecialcase_ = "specialize:memo"
 _subclass_cache = {}
@@ -140,24 +133,20 @@
     name = cls.__name__ + "User"
 
     mixins_needed = []
-    copy_methods = []
-    mixins_needed = []
-    name = cls.__name__
-    if not cls.user_overridden_class:
-        if cls is W_ObjectObject or cls is W_InstanceObject:
-            mixins_needed.append(_make_storage_mixin_size_n())
-        else:
-            mixins_needed.append(MapdictStorageMixin)
-        copy_methods = [BaseUserClassMapdict]
-        if reallywantdict or not typedef.hasdict:
-            # the type has no dict, mapdict to provide the dict
-            copy_methods.append(MapdictDictSupport)
-            name += "Dict"
-        if not typedef.weakrefable:
-            # the type does not support weakrefs yet, mapdict to provide 
weakref
-            # support
-            copy_methods.append(MapdictWeakrefSupport)
-            name += "Weakrefable"
+    if cls is W_ObjectObject or cls is W_InstanceObject:
+        mixins_needed.append(_make_storage_mixin_size_n())
+    else:
+        mixins_needed.append(MapdictStorageMixin)
+    copy_methods = [BaseUserClassMapdict]
+    if reallywantdict or not typedef.hasdict:
+        # the type has no dict, mapdict to provide the dict
+        copy_methods.append(MapdictDictSupport)
+        name += "Dict"
+    if not typedef.weakrefable:
+        # the type does not support weakrefs yet, mapdict to provide weakref
+        # support
+        copy_methods.append(MapdictWeakrefSupport)
+        name += "Weakrefable"
     if wants_del:
         # This subclass comes with an app-level __del__.  To handle
         # it, we make an RPython-level __del__ method.  This
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to