summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorscaramallion <scaramallion@users.noreply.github.com>2020-10-18 14:49:48 (GMT)
committerGitHub <noreply@github.com>2020-10-18 14:49:48 (GMT)
commitc304c9a7efa8751b5bc7526fa95cd5f30aac2b92 (patch)
tree0a255fff66b458eb49c0357d36298c59e7fbf0f6 /Lib
parenta0c603cb9d4dbb9909979313a88bcd1f5fde4f62 (diff)
downloadcpython-c304c9a7efa8751b5bc7526fa95cd5f30aac2b92.zip
cpython-c304c9a7efa8751b5bc7526fa95cd5f30aac2b92.tar.gz
cpython-c304c9a7efa8751b5bc7526fa95cd5f30aac2b92.tar.bz2
bpo-41966: Fix pickling pure datetime.time subclasses (GH-22731)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/datetime.py2
-rw-r--r--Lib/test/datetimetester.py3
2 files changed, 4 insertions, 1 deletions
diff --git a/Lib/datetime.py b/Lib/datetime.py
index ea86bcb..b896b94 100644
--- a/Lib/datetime.py
+++ b/Lib/datetime.py
@@ -1548,7 +1548,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 8b61c26..775d315 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -1781,6 +1781,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.
@@ -2308,6 +2309,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 = [
@@ -3357,6 +3359,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 = [