[pypy-commit] pypy py3.3: Be consistent and raise the same RuntimeError for unacquired locks

amauryfa noreply at buildbot.pypy.org
Tue Mar 10 21:56:51 CET 2015


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3.3
Changeset: r76306:c4010a0d5561
Date: 2015-03-10 15:20 +0100
http://bitbucket.org/pypy/pypy/changeset/c4010a0d5561/

Log:	Be consistent and raise the same RuntimeError for unacquired locks

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
@@ -89,7 +89,8 @@
         try:
             self.lock.release()
         except rthread.error:
-            raise wrap_thread_error(space, "release unlocked lock")
+            raise OperationError(space.w_RuntimeError, space.wrap(
+                "cannot release un-acquired lock"))
 
     def descr_lock_locked(self, space):
         """Return whether the lock is in the locked state."""
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
@@ -12,7 +12,7 @@
         lock = _thread.allocate_lock()
         assert type(lock) is _thread.LockType
         assert lock.locked() is False
-        raises(_thread.error, lock.release)
+        raises(RuntimeError, lock.release)
         assert lock.locked() is False
         r = lock.acquire()
         assert r is True
@@ -21,7 +21,7 @@
         assert lock.locked() is True
         lock.release()
         assert lock.locked() is False
-        raises(_thread.error, lock.release)
+        raises(RuntimeError, lock.release)
         assert lock.locked() is False
         feedback = []
         lock.acquire()


More information about the pypy-commit mailing list