bpo-41966: Fix pickling pure datetime.time subclasses (GH-22731)
This commit is contained in:
parent
a0c603cb9d
commit
c304c9a7ef
|
@ -1548,7 +1548,7 @@ class time:
|
||||||
self._tzinfo = tzinfo
|
self._tzinfo = tzinfo
|
||||||
|
|
||||||
def __reduce_ex__(self, protocol):
|
def __reduce_ex__(self, protocol):
|
||||||
return (time, self._getstate(protocol))
|
return (self.__class__, self._getstate(protocol))
|
||||||
|
|
||||||
def __reduce__(self):
|
def __reduce__(self):
|
||||||
return self.__reduce_ex__(2)
|
return self.__reduce_ex__(2)
|
||||||
|
|
|
@ -1781,6 +1781,7 @@ class TestDate(HarmlessMixedComparison, unittest.TestCase):
|
||||||
green = pickler.dumps(orig, proto)
|
green = pickler.dumps(orig, proto)
|
||||||
derived = unpickler.loads(green)
|
derived = unpickler.loads(green)
|
||||||
self.assertEqual(orig, derived)
|
self.assertEqual(orig, derived)
|
||||||
|
self.assertTrue(isinstance(derived, SubclassDate))
|
||||||
|
|
||||||
def test_backdoor_resistance(self):
|
def test_backdoor_resistance(self):
|
||||||
# For fast unpickling, the constructor accepts a pickle byte string.
|
# For fast unpickling, the constructor accepts a pickle byte string.
|
||||||
|
@ -2308,6 +2309,7 @@ class TestDateTime(TestDate):
|
||||||
green = pickler.dumps(orig, proto)
|
green = pickler.dumps(orig, proto)
|
||||||
derived = unpickler.loads(green)
|
derived = unpickler.loads(green)
|
||||||
self.assertEqual(orig, derived)
|
self.assertEqual(orig, derived)
|
||||||
|
self.assertTrue(isinstance(derived, SubclassDatetime))
|
||||||
|
|
||||||
def test_compat_unpickle(self):
|
def test_compat_unpickle(self):
|
||||||
tests = [
|
tests = [
|
||||||
|
@ -3357,6 +3359,7 @@ class TestTime(HarmlessMixedComparison, unittest.TestCase):
|
||||||
green = pickler.dumps(orig, proto)
|
green = pickler.dumps(orig, proto)
|
||||||
derived = unpickler.loads(green)
|
derived = unpickler.loads(green)
|
||||||
self.assertEqual(orig, derived)
|
self.assertEqual(orig, derived)
|
||||||
|
self.assertTrue(isinstance(derived, SubclassTime))
|
||||||
|
|
||||||
def test_compat_unpickle(self):
|
def test_compat_unpickle(self):
|
||||||
tests = [
|
tests = [
|
||||||
|
|
|
@ -787,6 +787,7 @@ Meador Inge
|
||||||
Peter Ingebretson
|
Peter Ingebretson
|
||||||
Tony Ingraldi
|
Tony Ingraldi
|
||||||
John Interrante
|
John Interrante
|
||||||
|
Dean Inwood
|
||||||
Bob Ippolito
|
Bob Ippolito
|
||||||
Roger Irwin
|
Roger Irwin
|
||||||
Atsuo Ishimoto
|
Atsuo Ishimoto
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix pickling pure Python :class:`datetime.time` subclasses. Patch by Dean
|
||||||
|
Inwood.
|
Loading…
Reference in New Issue