mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	sqlite3: Fix 64-bit integer handling in user functions on 32-bit architectures
Closes #8033.
This commit is contained in:
		
							parent
							
								
									29877e8e04
								
							
						
					
					
						commit
						4fe85abab9
					
				
					 4 changed files with 24 additions and 6 deletions
				
			
		|  | @ -37,6 +37,8 @@ def func_returnnull(): | |||
|     return None | ||||
| def func_returnblob(): | ||||
|     return b"blob" | ||||
| def func_returnlonglong(): | ||||
|     return 1<<31 | ||||
| def func_raiseexception(): | ||||
|     5/0 | ||||
| 
 | ||||
|  | @ -50,6 +52,8 @@ def func_isnone(v): | |||
|     return type(v) is type(None) | ||||
| def func_isblob(v): | ||||
|     return isinstance(v, (bytes, memoryview)) | ||||
| def func_islonglong(v): | ||||
|     return isinstance(v, int) and v >= 1<<31 | ||||
| 
 | ||||
| class AggrNoStep: | ||||
|     def __init__(self): | ||||
|  | @ -127,6 +131,7 @@ def setUp(self): | |||
|         self.con.create_function("returnfloat", 0, func_returnfloat) | ||||
|         self.con.create_function("returnnull", 0, func_returnnull) | ||||
|         self.con.create_function("returnblob", 0, func_returnblob) | ||||
|         self.con.create_function("returnlonglong", 0, func_returnlonglong) | ||||
|         self.con.create_function("raiseexception", 0, func_raiseexception) | ||||
| 
 | ||||
|         self.con.create_function("isstring", 1, func_isstring) | ||||
|  | @ -134,6 +139,7 @@ def setUp(self): | |||
|         self.con.create_function("isfloat", 1, func_isfloat) | ||||
|         self.con.create_function("isnone", 1, func_isnone) | ||||
|         self.con.create_function("isblob", 1, func_isblob) | ||||
|         self.con.create_function("islonglong", 1, func_islonglong) | ||||
| 
 | ||||
|     def tearDown(self): | ||||
|         self.con.close() | ||||
|  | @ -200,6 +206,12 @@ def CheckFuncReturnBlob(self): | |||
|         self.assertEqual(type(val), bytes) | ||||
|         self.assertEqual(val, b"blob") | ||||
| 
 | ||||
|     def CheckFuncReturnLongLong(self): | ||||
|         cur = self.con.cursor() | ||||
|         cur.execute("select returnlonglong()") | ||||
|         val = cur.fetchone()[0] | ||||
|         self.assertEqual(val, 1<<31) | ||||
| 
 | ||||
|     def CheckFuncException(self): | ||||
|         cur = self.con.cursor() | ||||
|         try: | ||||
|  | @ -239,6 +251,12 @@ def CheckParamBlob(self): | |||
|         val = cur.fetchone()[0] | ||||
|         self.assertEqual(val, 1) | ||||
| 
 | ||||
|     def CheckParamLongLong(self): | ||||
|         cur = self.con.cursor() | ||||
|         cur.execute("select islonglong(?)", (1<<42,)) | ||||
|         val = cur.fetchone()[0] | ||||
|         self.assertEqual(val, 1) | ||||
| 
 | ||||
| class AggregateTests(unittest.TestCase): | ||||
|     def setUp(self): | ||||
|         self.con = sqlite.connect(":memory:") | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Petri Lehtinen
						Petri Lehtinen