summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/datetime.py2
-rw-r--r--Lib/test/datetimetester.py3
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS.d/next/Library/2020-10-17-07-52-53.bpo-41966.gwEQRZ.rst2
4 files changed, 7 insertions, 1 deletions
diff --git a/Lib/datetime.py b/Lib/datetime.py
index 96d112c..9777e88 100644
--- a/Lib/datetime.py
+++ b/Lib/datetime.py
@@ -1545,7 +1545,7 @@ class time:
self._tzinfo = tzinfo
def __reduce_ex__(self, protocol):
- return (time, self._getstate(protocol))
+ return (self.__class__, self._getstate(protocol))
def __reduce__(self):
return self.__reduce_ex__(2)
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index d1a3c2f..bb94f8f 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -1750,6 +1750,7 @@ class TestDate(HarmlessMixedComparison, unittest.TestCase):
green = pickler.dumps(orig, proto)
derived = unpickler.loads(green)
self.assertEqual(orig, derived)
+ self.assertTrue(isinstance(derived, SubclassDate))
def test_backdoor_resistance(self):
# For fast unpickling, the constructor accepts a pickle byte string.
@@ -2277,6 +2278,7 @@ class TestDateTime(TestDate):
green = pickler.dumps(orig, proto)
derived = unpickler.loads(green)
self.assertEqual(orig, derived)
+ self.assertTrue(isinstance(derived, SubclassDatetime))
def test_compat_unpickle(self):
tests = [
@@ -3326,6 +3328,7 @@ class TestTime(HarmlessMixedComparison, unittest.TestCase):
green = pickler.dumps(orig, proto)
derived = unpickler.loads(green)
self.assertEqual(orig, derived)
+ self.assertTrue(isinstance(derived, SubclassTime))
def test_compat_unpickle(self):
tests = [
diff --git a/Misc/ACKS b/Misc/ACKS
index 8d355da..5584d5d 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -759,6 +759,7 @@ Meador Inge
Peter Ingebretson
Tony Ingraldi
John Interrante
+Dean Inwood
Bob Ippolito
Roger Irwin
Atsuo Ishimoto
diff --git a/Misc/NEWS.d/next/Library/2020-10-17-07-52-53.bpo-41966.gwEQRZ.rst b/Misc/NEWS.d/next/Library/2020-10-17-07-52-53.bpo-41966.gwEQRZ.rst
new file mode 100644
index 0000000..0e7fad4
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-10-17-07-52-53.bpo-41966.gwEQRZ.rst
@@ -0,0 +1,2 @@
+Fix pickling pure Python :class:`datetime.time` subclasses. Patch by Dean
+Inwood.