diff options
| author | Miss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-10-18 15:32:56 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-18 15:32:56 (GMT) |
| commit | a055ced9d43630cadc3c1d5edab0884f2c5131ea (patch) | |
| tree | 3bd0b566757d2a49bc23df33b162ae345ab1c7e2 | |
| parent | 6a2aa4994e99ae8e43011a0290646fde4724a003 (diff) | |
| download | cpython-a055ced9d43630cadc3c1d5edab0884f2c5131ea.zip cpython-a055ced9d43630cadc3c1d5edab0884f2c5131ea.tar.gz cpython-a055ced9d43630cadc3c1d5edab0884f2c5131ea.tar.bz2 | |
bpo-41966: Fix pickling pure datetime.time subclasses (GH-22731) (GH-22747)
(cherry picked from commit c304c9a7efa8751b5bc7526fa95cd5f30aac2b92)
Co-authored-by: scaramallion <scaramallion@users.noreply.github.com>
| -rw-r--r-- | Lib/datetime.py | 2 | ||||
| -rw-r--r-- | Lib/test/datetimetester.py | 3 | ||||
| -rw-r--r-- | Misc/ACKS | 1 | ||||
| -rw-r--r-- | Misc/NEWS.d/next/Library/2020-10-17-07-52-53.bpo-41966.gwEQRZ.rst | 2 |
4 files changed, 7 insertions, 1 deletions
diff --git a/Lib/datetime.py b/Lib/datetime.py index 2294ac2..e508d99 100644 --- a/Lib/datetime.py +++ b/Lib/datetime.py @@ -1579,7 +1579,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 a9741d6..b37ef91 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 = [ @@ -781,6 +781,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. |
