bpo-41966: Fix pickling pure datetime.time subclasses (GH-22731) (GH-22748)
(cherry picked from commit c304c9a7ef
)
Co-authored-by: scaramallion <scaramallion@users.noreply.github.com>
This commit is contained in:
parent
400175ad91
commit
1040299e92
|
@ -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)
|
||||
|
|
|
@ -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 = [
|
||||
|
|
|
@ -759,6 +759,7 @@ Meador Inge
|
|||
Peter Ingebretson
|
||||
Tony Ingraldi
|
||||
John Interrante
|
||||
Dean Inwood
|
||||
Bob Ippolito
|
||||
Roger Irwin
|
||||
Atsuo Ishimoto
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Fix pickling pure Python :class:`datetime.time` subclasses. Patch by Dean
|
||||
Inwood.
|
Loading…
Reference in New Issue