Author: Armin Rigo <ar...@tunes.org> Branch: py3.5 Changeset: r89908:885116967761 Date: 2017-02-03 12:43 +0100 http://bitbucket.org/pypy/pypy/changeset/885116967761/
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 @@ -522,8 +522,18 @@ @unwrap_spec(kind=int, maxvalue=int) def rebuild(space, w_cls, w_handle, kind, maxvalue, w_name): name = space.str_or_None_w(w_name) + # + if sys.platform != 'win32' and name is not None: + # like CPython, in this case ignore 'w_handle' + try: + handle = create_semaphore(space, name, 0, maxvalue) + except OSError as e: + raise wrap_oserror(space, e) + else: + handle = handle_w(space, w_handle) + # self = space.allocate_instance(W_SemLock, w_cls) - self.__init__(space, handle_w(space, w_handle), kind, maxvalue, name) + self.__init__(space, handle, kind, maxvalue, name) return space.wrap(self) def enter(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 @@ -108,7 +108,9 @@ maxvalue = 1 sem = SemLock(kind, value, maxvalue, "4", unlink=True) - sem2 = SemLock._rebuild(sem.handle, kind, value, "10") + sem2 = SemLock._rebuild(sem.handle, kind, value, "92") + assert sem.handle != sem2.handle + sem2 = SemLock._rebuild(sem.handle, kind, value, None) assert sem.handle == sem2.handle def test_semaphore_contextmanager(self): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit