mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	Merge 3.6
This commit is contained in:
		
						commit
						7ed28a8914
					
				
					 4 changed files with 41 additions and 18 deletions
				
			
		|  | @ -4,6 +4,7 @@ | |||
| the latter should be modernized). | ||||
| """ | ||||
| 
 | ||||
| import array | ||||
| import os | ||||
| import re | ||||
| import sys | ||||
|  | @ -81,6 +82,18 @@ def test_from_index(self): | |||
|         self.assertRaises(ValueError, self.type2test, [Indexable(-1)]) | ||||
|         self.assertRaises(ValueError, self.type2test, [Indexable(256)]) | ||||
| 
 | ||||
|     def test_from_buffer(self): | ||||
|         a = self.type2test(array.array('B', [1, 2, 3])) | ||||
|         self.assertEqual(a, b"\x01\x02\x03") | ||||
| 
 | ||||
|         # http://bugs.python.org/issue29159 | ||||
|         # Fallback when __index__ raises exception other than OverflowError | ||||
|         class B(bytes): | ||||
|             def __index__(self): | ||||
|                 raise TypeError | ||||
| 
 | ||||
|         self.assertEqual(self.type2test(B(b"foobar")), b"foobar") | ||||
| 
 | ||||
|     def test_from_ssize(self): | ||||
|         self.assertEqual(self.type2test(0), b'') | ||||
|         self.assertEqual(self.type2test(1), b'\x00') | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 INADA Naoki
						INADA Naoki