mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.14] gh-134322: Fix repr(threading.RLock)
(GH-134389) (#134528)
gh-134322: Fix `repr(threading.RLock)` (GH-134389)
Fix the `__repr__` value of `threading.RLock` from `_thread` module, when just created.
(cherry picked from commit fade146cfb
)
Co-authored-by: Duprat <yduprat@gmail.com>
This commit is contained in:
parent
bbf8048c0f
commit
068d570be8
3 changed files with 28 additions and 1 deletions
|
@ -1208,7 +1208,13 @@ rlock_repr(PyObject *op)
|
|||
rlockobject *self = rlockobject_CAST(op);
|
||||
PyThread_ident_t owner = self->lock.thread;
|
||||
int locked = rlock_locked_impl(self);
|
||||
size_t count = self->lock.level + 1;
|
||||
size_t count;
|
||||
if (locked) {
|
||||
count = self->lock.level + 1;
|
||||
}
|
||||
else {
|
||||
count = 0;
|
||||
}
|
||||
return PyUnicode_FromFormat(
|
||||
"<%s %s object owner=%" PY_FORMAT_THREAD_IDENT_T " count=%zu at %p>",
|
||||
locked ? "locked" : "unlocked",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue