[pypy-svn] r46681 - in pypy/dist/pypy: annotation translator/c/test

arigo at codespeak.net arigo at codespeak.net
Sun Sep 16 19:24:34 CEST 2007


Author: arigo
Date: Sun Sep 16 19:24:34 2007
New Revision: 46681

Modified:
   pypy/dist/pypy/annotation/builtin.py
   pypy/dist/pypy/translator/c/test/test_boehm.py
Log:
Require an annotation-time proof that we don't do weakref.ref(None).


Modified: pypy/dist/pypy/annotation/builtin.py
==============================================================================
--- pypy/dist/pypy/annotation/builtin.py	(original)
+++ pypy/dist/pypy/annotation/builtin.py	Sun Sep 16 19:24:34 2007
@@ -568,6 +568,9 @@
 def weakref_ref(s_obj):
     if not isinstance(s_obj, SomeInstance):
         raise Exception("cannot take a weakref to %r" % (s_obj,))
+    if s_obj.can_be_None:
+        raise Exception("should assert that the instance we take "
+                        "a weakref to cannot be None")
     return SomeWeakRef(s_obj.classdef)
 
 BUILTIN_ANALYZERS[weakref.ref] = weakref_ref

Modified: pypy/dist/pypy/translator/c/test/test_boehm.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_boehm.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_boehm.py	Sun Sep 16 19:24:34 2007
@@ -268,6 +268,7 @@
                 if i & 1 == 0:
                     a = A()
                     a.index = i
+                assert a is not None
                 weakrefs.append(weakref.ref(a))
                 if i % 7 == 6:
                     keepalive.append(a)



More information about the Pypy-commit mailing list