mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Issue #26202: copy.deepcopy() now correctly copies range() objects with
non-atomic attributes.
This commit is contained in:
		
							parent
							
								
									d5db57396b
								
							
						
					
					
						commit
						0a20bbf669
					
				
					 3 changed files with 15 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -207,7 +207,6 @@ def _deepcopy_atomic(x, memo):
 | 
			
		|||
except AttributeError:
 | 
			
		||||
    pass
 | 
			
		||||
d[type] = _deepcopy_atomic
 | 
			
		||||
d[range] = _deepcopy_atomic
 | 
			
		||||
d[types.BuiltinFunctionType] = _deepcopy_atomic
 | 
			
		||||
d[types.FunctionType] = _deepcopy_atomic
 | 
			
		||||
d[weakref.ref] = _deepcopy_atomic
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -314,7 +314,7 @@ def f():
 | 
			
		|||
            pass
 | 
			
		||||
        tests = [None, 42, 2**100, 3.14, True, False, 1j,
 | 
			
		||||
                 "hello", "hello\u1234", f.__code__,
 | 
			
		||||
                 NewStyle, range(10), Classic, max]
 | 
			
		||||
                 NewStyle, Classic, max]
 | 
			
		||||
        for x in tests:
 | 
			
		||||
            self.assertIs(copy.deepcopy(x), x)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -536,6 +536,17 @@ class C:
 | 
			
		|||
        self.assertIsNot(y, x)
 | 
			
		||||
        self.assertIs(y.foo, y)
 | 
			
		||||
 | 
			
		||||
    def test_deepcopy_range(self):
 | 
			
		||||
        class I(int):
 | 
			
		||||
            pass
 | 
			
		||||
        x = range(I(10))
 | 
			
		||||
        y = copy.deepcopy(x)
 | 
			
		||||
        self.assertIsNot(y, x)
 | 
			
		||||
        self.assertEqual(y, x)
 | 
			
		||||
        self.assertIsNot(y.stop, x.stop)
 | 
			
		||||
        self.assertEqual(y.stop, x.stop)
 | 
			
		||||
        self.assertIsInstance(y.stop, I)
 | 
			
		||||
 | 
			
		||||
    # _reconstruct()
 | 
			
		||||
 | 
			
		||||
    def test_reconstruct_string(self):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -66,6 +66,9 @@ Core and Builtins
 | 
			
		|||
Library
 | 
			
		||||
-------
 | 
			
		||||
 | 
			
		||||
- Issue #26202: copy.deepcopy() now correctly copies range() objects with
 | 
			
		||||
  non-atomic attributes.
 | 
			
		||||
 | 
			
		||||
- Issue #19883: Fixed possible integer overflows in zipimport.
 | 
			
		||||
 | 
			
		||||
- Issue #26227: On Windows, getnameinfo(), gethostbyaddr() and
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue