all Python 3Exceptionsexception
copy.Error
module exceptions
Raised by the copy module when an object cannot be copied.
Syntax
raise copy.Error
Catching this alone is not enough: most uncopyable objects (sockets, locks, open files) fail with TypeError from the pickle machinery, and copy.Error is left for objects that define neither __copy__/__deepcopy__ nor __reduce_ex__. So when copying objects you did not write, catch copy.Error and TypeError together — or simply do not copy anything that holds an external resource.
Examples
import copy
try:
raise copy.Error
except copy.Error as e:
print(type(e).__name__) # → Error
See also
Open in the full glossarydocs.python.orgReport an inaccuracy