summaryrefslogtreecommitdiffstats
path: root/Lib/datetime.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-11-21 22:30:32 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-11-21 22:30:32 (GMT)
commite425bd95e9f3ceb767e1894cce8cc01a63e7013b (patch)
tree8435dbd2639fe696b8c65fcb728a1281717daff7 /Lib/datetime.py
parent4ea37703acae519fcf0bcd23a6821e2972993789 (diff)
parent546ce65968921f52f1c79a7218e57dc237dbe436 (diff)
downloadcpython-e425bd95e9f3ceb767e1894cce8cc01a63e7013b.zip
cpython-e425bd95e9f3ceb767e1894cce8cc01a63e7013b.tar.gz
cpython-e425bd95e9f3ceb767e1894cce8cc01a63e7013b.tar.bz2
Issue #28752: Restored the __reduce__() methods of datetime objects.
Diffstat (limited to 'Lib/datetime.py')
-rw-r--r--Lib/datetime.py12
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)