mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	[3.13] gh-82951: Fix serializing by name in pickle protocols < 4 (GH-122149) (GH-122264)
Serializing objects with complex __qualname__ (such as unbound methods and
nested classes) by name no longer involves serializing parent objects by value
in pickle protocols < 4.
(cherry picked from commit dc07f65a53)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
			
			
This commit is contained in:
		
							parent
							
								
									977c799286
								
							
						
					
					
						commit
						984f8aaa2f
					
				
					 4 changed files with 82 additions and 26 deletions
				
			
		|  | @ -2818,6 +2818,18 @@ class Recursive: | |||
|                 self.assertIs(unpickled, Recursive) | ||||
|         del Recursive.mod # break reference loop | ||||
| 
 | ||||
|     def test_recursive_nested_names2(self): | ||||
|         global Recursive | ||||
|         class Recursive: | ||||
|             pass | ||||
|         Recursive.ref = Recursive | ||||
|         Recursive.__qualname__ = 'Recursive.ref' | ||||
|         for proto in range(pickle.HIGHEST_PROTOCOL + 1): | ||||
|             with self.subTest(proto=proto): | ||||
|                 unpickled = self.loads(self.dumps(Recursive, proto)) | ||||
|                 self.assertIs(unpickled, Recursive) | ||||
|         del Recursive.ref # break reference loop | ||||
| 
 | ||||
|     def test_py_methods(self): | ||||
|         global PyMethodsTest | ||||
|         class PyMethodsTest: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)