mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	bpo-41966: Fix pickling pure datetime.time subclasses (GH-22731) (GH-22747)
(cherry picked from commit c304c9a7ef)
Co-authored-by: scaramallion <scaramallion@users.noreply.github.com>
			
			
This commit is contained in:
		
							parent
							
								
									6a2aa4994e
								
							
						
					
					
						commit
						a055ced9d4
					
				
					 4 changed files with 7 additions and 1 deletions
				
			
		|  | @ -1579,7 +1579,7 @@ def __setstate(self, string, tzinfo): | |||
|         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) | ||||
|  |  | |||
|  | @ -1781,6 +1781,7 @@ def test_pickling_subclass_date(self): | |||
|             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 @@ def test_pickling_subclass_datetime(self): | |||
|             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 @@ def test_pickling_subclass_time(self): | |||
|             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 | ||||
|  |  | |||
|  | @ -0,0 +1,2 @@ | |||
| Fix pickling pure Python :class:`datetime.time` subclasses. Patch by Dean | ||||
| Inwood. | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Skeleton (bot)
						Miss Skeleton (bot)