Commit f3b12b1d authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

improve pickle size of DateTime.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18319 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d89aaddd
...@@ -31,20 +31,18 @@ from DateTime import DateTime as DateTimeKlass ...@@ -31,20 +31,18 @@ from DateTime import DateTime as DateTimeKlass
STATE_KEY = 'str' STATE_KEY = 'str'
def DateTime__setstate__(self, state): def DateTime__setstate__(self, state):
if len(state) != 1 or STATE_KEY not in state: if isinstance(state, tuple):
self._parse_args(*state)
elif len(state) != 1 or STATE_KEY not in state:
# For original pickle representation
self.__dict__.update(state) self.__dict__.update(state)
else: else:
# For backward compatibility # For r15569 implementation
self._parse_args(state[STATE_KEY]) self._parse_args(state[STATE_KEY])
DateTimeKlass.__setstate__ = DateTime__setstate__ DateTimeKlass.__setstate__ = DateTime__setstate__
# This below is disabled, because this loses information at def DateTime__getstate__(self):
# millisecond level, and it breaks the simulation due to return (self._t, self._tz)
# divergency tests. I will not disable the above for backward
# compatibility. -yo DateTimeKlass.__getstate__ = DateTime__getstate__
#
# def DateTime__getstate__(self):
# return {STATE_KEY: str(self)}
#
# DateTimeKlass.__getstate__ = DateTime__getstate__
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment