[pypy-svn] r46404 - pypy/dist/pypy/module/_weakref

arigo at codespeak.net arigo at codespeak.net
Fri Sep 7 16:11:45 CEST 2007


Author: arigo
Date: Fri Sep  7 16:11:44 2007
New Revision: 46404

Modified:
   pypy/dist/pypy/module/_weakref/interp__weakref.py
Log:
Forbid user-created weakrefs in a sandbox translation
to avoid segfault-related issues.


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	Fri Sep  7 16:11:44 2007
@@ -122,9 +122,16 @@
         self.w_hash = self.space.hash(w_obj)
         return self.w_hash
 
+def check(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))
+
 def descr__new__weakref(space, w_subtype, w_obj, w_callable=None):
     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)
@@ -196,6 +203,7 @@
 is about to be finalized."""
     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)



More information about the Pypy-commit mailing list