[pypy-svn] r46435 - in pypy/dist/pypy: module/_weakref objspace/std
arigo at codespeak.net
arigo at codespeak.net
Mon Sep 10 13:38:29 CEST 2007
Author: arigo
Date: Mon Sep 10 13:38:29 2007
New Revision: 46435
Modified:
pypy/dist/pypy/module/_weakref/interp__weakref.py
pypy/dist/pypy/objspace/std/typeobject.py
Log:
Disable type.__subclasses__() in a sandbox translation,
to be fully weakref-free.
Modified: pypy/dist/pypy/module/_weakref/interp__weakref.py
==============================================================================
--- pypy/dist/pypy/module/_weakref/interp__weakref.py (original)
+++ pypy/dist/pypy/module/_weakref/interp__weakref.py Mon Sep 10 13:38:29 2007
@@ -129,9 +129,9 @@
space.wrap(msg))
def descr__new__weakref(space, w_subtype, w_obj, w_callable=None):
+ check(space)
lifeline = w_obj.getweakref()
if lifeline is None:
- check(space)
lifeline = WeakrefLifeline()
w_obj.setweakref(space, lifeline)
return lifeline.get_weakref(space, w_subtype, w_obj, w_callable)
@@ -201,9 +201,9 @@
"""Create a proxy object that weakly references 'obj'.
'callback', if given, is called with the proxy as an argument when 'obj'
is about to be finalized."""
+ check(space)
lifeline = w_obj.getweakref()
if lifeline is None:
- check(space)
lifeline = WeakrefLifeline()
w_obj.setweakref(space, lifeline)
return lifeline.get_proxy(space, w_obj, w_callable)
@@ -268,6 +268,7 @@
"""this is a bit like the app-level weakref.ref(), but with no
fancy options like supporting subclasses of _weakref.ref and
callbacks."""
+ check(space)
lifeline = w_obj.getweakref()
if lifeline is None:
lifeline = WeakrefLifeline()
Modified: pypy/dist/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/typeobject.py (original)
+++ pypy/dist/pypy/objspace/std/typeobject.py Mon Sep 10 13:38:29 2007
@@ -403,6 +403,8 @@
def add_subclass(w_self, w_subclass):
space = w_self.space
+ if space.config.translation.sandbox:
+ return # XXX weakrefs are disabled in a sandbox translation ATM
from pypy.module._weakref.interp__weakref import basic_weakref
w_newref = basic_weakref(space, w_subclass)
@@ -417,6 +419,8 @@
def remove_subclass(w_self, w_subclass):
space = w_self.space
+ if space.config.translation.sandbox:
+ return # XXX weakrefs are disabled in a sandbox translation ATM
for i in range(len(w_self.weak_subclasses_w)):
w_ref = w_self.weak_subclasses_w[i]
@@ -427,6 +431,11 @@
def get_subclasses(w_self):
space = w_self.space
+ if space.config.translation.sandbox:
+ msg = ("weakrefs are disabled in a sandbox translation "
+ "at the moment")
+ raise OperationError(space.w_RuntimeError,
+ space.wrap(msg))
subclasses_w = []
for w_ref in w_self.weak_subclasses_w:
w_ob = space.call_function(w_ref)
More information about the Pypy-commit
mailing list