mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	Issue #27570: Avoid zero-length memcpy() calls with null source pointers
This commit is contained in:
		
							parent
							
								
									799520c91e
								
							
						
					
					
						commit
						be8da9c990
					
				
					 5 changed files with 40 additions and 15 deletions
				
			
		|  | @ -38,14 +38,24 @@ def __init__(self, typecode, newarg=None): | |||
| if have_long_long: | ||||
|     typecodes += 'qQ' | ||||
| 
 | ||||
| class BadConstructorTest(unittest.TestCase): | ||||
| class MiscTest(unittest.TestCase): | ||||
| 
 | ||||
|     def test_constructor(self): | ||||
|     def test_bad_constructor(self): | ||||
|         self.assertRaises(TypeError, array.array) | ||||
|         self.assertRaises(TypeError, array.array, spam=42) | ||||
|         self.assertRaises(TypeError, array.array, 'xx') | ||||
|         self.assertRaises(ValueError, array.array, 'x') | ||||
| 
 | ||||
|     def test_empty(self): | ||||
|         # Exercise code for handling zero-length arrays | ||||
|         a = array.array('B') | ||||
|         a[:] = a | ||||
|         self.assertEqual(len(a), 0) | ||||
|         self.assertEqual(len(a + a), 0) | ||||
|         self.assertEqual(len(a * 3), 0) | ||||
|         a += a | ||||
|         self.assertEqual(len(a), 0) | ||||
| 
 | ||||
| 
 | ||||
| # Machine format codes. | ||||
| # | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Martin Panter
						Martin Panter