[pypy-svn] r24151 - in pypy/dist/pypy/objspace: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Thu Mar 9 10:18:59 CET 2006


Author: cfbolz
Date: Thu Mar  9 10:18:58 2006
New Revision: 24151

Modified:
   pypy/dist/pypy/objspace/logic.py
   pypy/dist/pypy/objspace/test/test_logicobjspace.py
Log:
do something more sensible when trying to use a logic variable


Modified: pypy/dist/pypy/objspace/logic.py
==============================================================================
--- pypy/dist/pypy/objspace/logic.py	(original)
+++ pypy/dist/pypy/objspace/logic.py	Thu Mar  9 10:18:58 2006
@@ -18,7 +18,8 @@
         w_bound_to = w_bound_to.w_bound_to
     if w_bound_to is None:
         # XXX here we would have to suspend the current thread
-        # for now just crash
+        raise OperationError(space.w_ValueError,
+                             space.wrap("trying to perform an operation on an unbound variable"))
         assert 0, "green threads not implemented yet"
     else:
         # actually attach the object directly to each variable

Modified: pypy/dist/pypy/objspace/test/test_logicobjspace.py
==============================================================================
--- pypy/dist/pypy/objspace/test/test_logicobjspace.py	(original)
+++ pypy/dist/pypy/objspace/test/test_logicobjspace.py	Thu Mar  9 10:18:58 2006
@@ -43,3 +43,8 @@
         for i in range(40):
             assert l[i] == 1
 
+    def test_use_unbound_var(self):
+        X = newvar()
+        def f(x):
+            return x + 1
+        raises(ValueError, f, X)



More information about the Pypy-commit mailing list