[pypy-commit] pypy refactor-wrapped-del: Pfffff.

arigo noreply at buildbot.pypy.org
Mon Jul 11 19:17:06 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: refactor-wrapped-del
Changeset: r45472:a528c8f27198
Date: 2011-07-11 14:36 +0200
http://bitbucket.org/pypy/pypy/changeset/a528c8f27198/

Log:	Pfffff.

diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -431,14 +431,17 @@
             return None
         assert isinstance(lifeline, WeakrefLifeline)
         return lifeline
+    getweakref._cannot_really_call_random_things_ = True
 
     def setweakref(self, space, weakreflifeline):
         from pypy.module._weakref.interp__weakref import WeakrefLifeline
         assert isinstance(weakreflifeline, WeakrefLifeline)
         self._get_mapdict_map().write(self, ("weakref", SPECIAL), weakreflifeline)
+    setweakref._cannot_really_call_random_things_ = True
 
     def delweakref(self):
         self._get_mapdict_map().write(self, ("weakref", SPECIAL), None)
+    delweakref._cannot_really_call_random_things_ = True
 
 class ObjectMixin(object):
     _mixin_ = True
diff --git a/pypy/rpython/rclass.py b/pypy/rpython/rclass.py
--- a/pypy/rpython/rclass.py
+++ b/pypy/rpython/rclass.py
@@ -393,8 +393,8 @@
             oldlength = len(seen)
             for caller, callee in callgraph:
                 if caller in seen and callee not in seen:
-                    if (hasattr(callee, 'func') and
-                        getattr(callee.func, '_dont_reach_me_in_del_',False)):
+                    func = getattr(callee, 'func', None)
+                    if getattr(func, '_dont_reach_me_in_del_', False):
                         lst = [str(callee)]
                         g = caller
                         while g:
@@ -404,6 +404,9 @@
                         raise TyperError("the RPython-level __del__() method "
                                          "in %r calls:%s" % (
                             graph, '\n\t'.join(lst[::-1])))
+                    if getattr(func, '_cannot_really_call_random_things_',
+                               False):
+                        continue
                     seen[callee] = caller
             if len(seen) == oldlength:
                 break


More information about the pypy-commit mailing list