mirror of https://github.com/python/cpython.git
Slight code rearrangement to avoid testing getstate twice.
This commit is contained in:
parent
45486176ea
commit
4fba220f4a
|
@ -417,6 +417,7 @@ def save_newobj(self, obj):
|
|||
|
||||
getstate = getattr(obj, "__getstate__", None)
|
||||
|
||||
if getstate:
|
||||
# A class may define both __getstate__ and __getnewargs__.
|
||||
# If they are the same function, we ignore __getstate__.
|
||||
# This is for the benefit of protocols 0 and 1, which don't
|
||||
|
@ -436,10 +437,9 @@ def save_newobj(self, obj):
|
|||
# that __getnewargs__ returns all the state there is
|
||||
# (which should be a safe assumption since __getstate__
|
||||
# returns the *same* state).
|
||||
if getstate and getstate == getnewargs:
|
||||
if getstate == getnewargs:
|
||||
return
|
||||
|
||||
if getstate:
|
||||
try:
|
||||
state = getstate()
|
||||
except TypeError, err:
|
||||
|
@ -450,6 +450,7 @@ def save_newobj(self, obj):
|
|||
print repr(str(err))
|
||||
raise # Not that specific exception
|
||||
getstate = None
|
||||
|
||||
if not getstate:
|
||||
state = getattr(obj, "__dict__", None)
|
||||
if not state:
|
||||
|
|
Loading…
Reference in New Issue