Author: Armin Rigo <ar...@tunes.org>
Branch: py3.5
Changeset: r89879:9dc20d26cd82
Date: 2017-02-01 14:27 +0100
http://bitbucket.org/pypy/pypy/changeset/9dc20d26cd82/

Log:    test and fix

diff --git a/pypy/module/_multiprocessing/interp_semaphore.py 
b/pypy/module/_multiprocessing/interp_semaphore.py
--- a/pypy/module/_multiprocessing/interp_semaphore.py
+++ b/pypy/module/_multiprocessing/interp_semaphore.py
@@ -216,9 +216,10 @@
 
     def semaphore_unlink(space, w_name):
         name = space.str_w(w_name)
-        res = _sem_unlink(name)
-        if res < 0:
-            raise oefmt(space.w_OSError, "sem unlink failed with errno: %d", 
rposix.get_saved_errno())
+        try:
+            sem_unlink(name)
+        except OSError as e:
+            raise wrap_oserror(space, e)
 
 class CounterState:
     def __init__(self, space):
diff --git a/pypy/module/_multiprocessing/test/test_semaphore.py 
b/pypy/module/_multiprocessing/test/test_semaphore.py
--- a/pypy/module/_multiprocessing/test/test_semaphore.py
+++ b/pypy/module/_multiprocessing/test/test_semaphore.py
@@ -22,10 +22,13 @@
     @py.test.mark.skipif("sys.platform == 'win32'")
     def test_sem_unlink(self):
         from _multiprocessing import sem_unlink
+        import errno
         try:
             sem_unlink("non-existent")
-        except OSError:
-            pass
+        except OSError as e:
+            assert e.errno in (errno.ENOENT, errno.EINVAL)
+        else:
+            assert 0, "should have raised"
 
     def test_semaphore(self):
         from _multiprocessing import SemLock
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to