Commit bc567885 authored by Jérome Perrin's avatar Jérome Perrin

DateTimePatch: document __setstate__ patch and make it support DateTime 4

parent 314c2db9
...@@ -35,10 +35,20 @@ SyntaxError, DateError, TimeError, localtime, time ...@@ -35,10 +35,20 @@ SyntaxError, DateError, TimeError, localtime, time
STATE_KEY = 'str' STATE_KEY = 'str'
# ERP5 Patch for different pickle implementation, to optimize for disk usage.
# We had different __getstate__ implementations, so we need __setstate__ to support
# loading these formats that might be present in ZODBs.
# This patch does not have support for timezone naive flag, because we don't need it
# so far and also probably because we did not notice that it was added in original
# DateTime.
original_DateTime__setstate__ = DateTimeKlass.__setstate__ original_DateTime__setstate__ = DateTimeKlass.__setstate__
def DateTime__setstate__(self, state): def DateTime__setstate__(self, state):
try: # BBB DateTime 2.12.8
self.__dict__.clear() self.__dict__.clear()
except AttributeError:
pass
self._timezone_naive = False
if isinstance(state, tuple): if isinstance(state, tuple):
t, tz = state t, tz = state
ms = (t - math.floor(t)) ms = (t - math.floor(t))
......
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