Skip to content

Commit b330172

Browse files
committed
Use single bit in the enum value
1 parent 42ba6e7 commit b330172

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Include/internal/pycore_lock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ typedef enum _PyLockFlags {
5454

5555
// Locking & unlocking this lock requires attached thread state.
5656
// If locking returns PY_LOCK_FAILURE, a Python exception *may* be raised.
57-
// Implies _PY_LOCK_HANDLE_SIGNALS and _PY_LOCK_DETACH.
58-
_PY_LOCK_PYTHONLOCK = 8 | 2 | 1,
57+
// (Intended for use with _PY_LOCK_HANDLE_SIGNALS and _PY_LOCK_DETACH.)
58+
_PY_LOCK_PYTHONLOCK = 8,
5959
} _PyLockFlags;
6060

6161
// Lock a mutex with an optional timeout and additional options. See

Modules/_threadmodule.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,9 @@ lock_PyThread_acquire_lock(PyObject *op, PyObject *args, PyObject *kwds)
834834
return NULL;
835835
}
836836

837-
PyLockStatus r = _PyMutex_LockTimed(&self->lock, timeout,
838-
_PY_LOCK_PYTHONLOCK);
837+
PyLockStatus r = _PyMutex_LockTimed(
838+
&self->lock, timeout,
839+
_PY_LOCK_PYTHONLOCK | _PY_LOCK_HANDLE_SIGNALS | _PY_LOCK_DETACH);
839840
if (r == PY_LOCK_INTR) {
840841
assert(PyErr_Occurred());
841842
return NULL;
@@ -1058,8 +1059,9 @@ rlock_acquire(PyObject *op, PyObject *args, PyObject *kwds)
10581059
return NULL;
10591060
}
10601061

1061-
PyLockStatus r = _PyRecursiveMutex_LockTimed(&self->lock, timeout,
1062-
_PY_LOCK_PYTHONLOCK);
1062+
PyLockStatus r = _PyRecursiveMutex_LockTimed(
1063+
&self->lock, timeout,
1064+
_PY_LOCK_PYTHONLOCK | _PY_LOCK_HANDLE_SIGNALS | _PY_LOCK_DETACH);
10631065
if (r == PY_LOCK_INTR) {
10641066
assert(PyErr_Occurred());
10651067
return NULL;

0 commit comments

Comments
 (0)