File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -337,6 +337,11 @@ class RLockTests(BaseLockTests):
337337 """
338338 Tests for recursive locks.
339339 """
340+ def test_locked_repr (self ):
341+ super ().test_locked_repr ()
342+ lock = self .locktype ()
343+ self .assertIn ("count=0" , repr (lock ))
344+
340345 def test_reacquire (self ):
341346 lock = self .locktype ()
342347 lock .acquire ()
Original file line number Diff line number Diff line change @@ -1219,7 +1219,8 @@ rlock_repr(PyObject *op)
12191219{
12201220 rlockobject * self = rlockobject_CAST (op );
12211221 PyThread_ident_t owner = self -> lock .thread ;
1222- size_t count = self -> lock .level + 1 ;
1222+ size_t count = _PyRecursiveMutex_IsLockedByCurrentThread (& self -> lock ) ?
1223+ self -> lock .level + 1 : 0 ;
12231224 return PyUnicode_FromFormat (
12241225 "<%s %s object owner=%" PY_FORMAT_THREAD_IDENT_T " count=%zu at %p>" ,
12251226 owner ? "locked" : "unlocked" ,
You can’t perform that action at this time.
0 commit comments