Bug report
Bug description:
import threading def main(): r = threading.RLock() print(f"{r = }") t = threading.Thread(target=r.acquire) t.start() t.join() print(f"{r = }") print(f"{r.locked() = } at {hex(id(r))}") if __name__ == '__main__': main()
Output is:
r = <unlocked _thread.RLock object owner=0 count=1 at 0x105a98720>
r = <locked _thread.RLock object owner=6106329088 count=1 at 0x105a98720>
r.locked() = False at 0x105a98720
Error is located at:
| def locked(self): | |
| """Return whether this object is locked.""" | |
| return self._count > 0 |
The return instruction must be: return self._block.locked().
I can submit a PR quickly.
CPython versions tested on:
CPython main branch, 3.14
Operating systems tested on:
macOS