summaryrefslogtreecommitdiffstats
path: root/Lib/copy_reg.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/copy_reg.py')
-rw-r--r--Lib/copy_reg.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/Lib/copy_reg.py b/Lib/copy_reg.py
index f4661ed..8760e62 100644
--- a/Lib/copy_reg.py
+++ b/Lib/copy_reg.py
@@ -23,18 +23,12 @@ def constructor(object):
if not callable(object):
raise TypeError("constructors must be callable")
-# Example: provide pickling support for complex numbers.
+# Example: provide pickling support for bytes objects.
-try:
- complex
-except NameError:
- pass
-else:
+def _pickle_bytes(b):
+ return bytes, (str(b),)
- def pickle_complex(c):
- return complex, (c.real, c.imag)
-
- pickle(complex, pickle_complex, complex)
+pickle(bytes, _pickle_bytes)
# Support for pickling new-style objects