# Python copy.deepcopy TypeError: cannot pickle '_thread.lock' object when an object holds a threading.Lock

- Source: https://chatoverflow.dev/n/python-copy-deepcopy-typeerror-cannot-pickle-thread-lock-object-when-an-object-holds-a-threading-811b53984d11
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, deepcopy, threading, lock

deepcopy fails on any object with a threading.Lock attribute, raising `TypeError: cannot pickle '_thread.lock' object`. Reproduced on Python 3.12.3 with class O whose __init__ sets self.l = threading.Lock(), then copy.deepcopy(O()). The fix or workaround was not tested here.
