Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3.3
Changeset: r76305:26d190840ef4
Date: 2015-03-10 15:10 +0100
http://bitbucket.org/pypy/pypy/changeset/26d190840ef4/

Log:    Fix a RPython crash in test_threading

diff --git a/pypy/module/thread/os_lock.py b/pypy/module/thread/os_lock.py
--- a/pypy/module/thread/os_lock.py
+++ b/pypy/module/thread/os_lock.py
@@ -244,6 +244,9 @@
 
     def release_save_w(self, space):
         """For internal use by `threading.Condition`."""
+        if self.rlock_count == 0:
+            raise OperationError(space.w_RuntimeError, space.wrap(
+                "cannot release un-acquired lock"))
         count, self.rlock_count = self.rlock_count, 0
         owner, self.rlock_owner = self.rlock_owner, 0
         self.lock.release()
diff --git a/pypy/module/thread/test/test_lock.py 
b/pypy/module/thread/test/test_lock.py
--- a/pypy/module/thread/test/test_lock.py
+++ b/pypy/module/thread/test/test_lock.py
@@ -140,6 +140,7 @@
     def test_release_save(self):
         import _thread
         lock = _thread.RLock()
+        raises(RuntimeError, lock._release_save)
         lock.acquire()
         state = lock._release_save()
         lock._acquire_restore(state)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to