diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-21 22:29:42 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-21 22:29:42 (GMT) |
commit | 546ce65968921f52f1c79a7218e57dc237dbe436 (patch) | |
tree | b63e6a32e8e0ca3893f6914367ecdbcd36e19c67 /Lib/datetime.py | |
parent | f89854f89c7d4f625ad8d35783a30b7a48bd0e76 (diff) | |
download | cpython-546ce65968921f52f1c79a7218e57dc237dbe436.zip cpython-546ce65968921f52f1c79a7218e57dc237dbe436.tar.gz cpython-546ce65968921f52f1c79a7218e57dc237dbe436.tar.bz2 |
Issue #28752: Restored the __reduce__() methods of datetime objects.
Diffstat (limited to 'Lib/datetime.py')
-rw-r--r-- | Lib/datetime.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/datetime.py b/Lib/datetime.py index 36374aa..7540109 100644 --- a/Lib/datetime.py +++ b/Lib/datetime.py @@ -932,7 +932,7 @@ class date: # Pickle support. - def _getstate(self, protocol=3): + def _getstate(self): yhi, ylo = divmod(self._year, 256) return bytes([yhi, ylo, self._month, self._day]), @@ -940,8 +940,8 @@ class date: yhi, ylo, self._month, self._day = string self._year = yhi * 256 + ylo - def __reduce_ex__(self, protocol): - return (self.__class__, self._getstate(protocol)) + def __reduce__(self): + return (self.__class__, self._getstate()) _date_class = date # so functions w/ args named "date" can get at the class @@ -1348,6 +1348,9 @@ class time: def __reduce_ex__(self, protocol): return (time, self._getstate(protocol)) + def __reduce__(self): + return self.__reduce_ex__(2) + _time_class = time # so functions w/ args named "time" can get at the class time.min = time(0, 0, 0) @@ -1923,6 +1926,9 @@ class datetime(date): def __reduce_ex__(self, protocol): return (self.__class__, self._getstate(protocol)) + def __reduce__(self): + return self.__reduce_ex__(2) + datetime.min = datetime(1, 1, 1) datetime.max = datetime(9999, 12, 31, 23, 59, 59, 999999) |