Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4e2491d

Browse files
committed
Add a comment about how some built-in types should grow a
__getnewargs__ method.
1 parent b26a97a commit 4e2491d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Lib/pickle.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,15 @@ def save_reduce(self, func, args, state=None):
368368

369369
def save_newobj(self, obj):
370370
# Save a new-style class instance, using protocol 2.
371-
# XXX Much of this is still experimental.
371+
# XXX This is still experimental.
372372
assert self.proto >= 2 # This only works for protocol 2
373373
t = type(obj)
374374
getnewargs = getattr(obj, "__getnewargs__", None)
375375
if getnewargs:
376376
args = getnewargs() # This bette not reference obj
377377
else:
378+
# XXX These types should each grow a __getnewargs__
379+
# implementation so this special-casing is unnecessary.
378380
for cls in int, long, float, complex, str, UnicodeType, tuple:
379381
if cls and isinstance(obj, cls):
380382
args = (cls(obj),)

0 commit comments

Comments
 (0)