mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Real pickling for bytes.
Restore complex pickling. Use cPickle in io.py.
This commit is contained in:
parent
0ad0812edb
commit
0dd32e246c
3 changed files with 29 additions and 6 deletions
|
@ -23,12 +23,18 @@ def constructor(object):
|
|||
if not callable(object):
|
||||
raise TypeError("constructors must be callable")
|
||||
|
||||
# Example: provide pickling support for bytes objects.
|
||||
# Example: provide pickling support for complex numbers.
|
||||
|
||||
def _pickle_bytes(b):
|
||||
return bytes, (str(b),)
|
||||
try:
|
||||
complex
|
||||
except NameError:
|
||||
pass
|
||||
else:
|
||||
|
||||
pickle(bytes, _pickle_bytes)
|
||||
def pickle_complex(c):
|
||||
return complex, (c.real, c.imag)
|
||||
|
||||
pickle(complex, pickle_complex, complex)
|
||||
|
||||
# Support for pickling new-style objects
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue