mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	bpo-41662: Fix bugs in binding parameters in sqlite3 (GH-21998)
* When the parameters argument is a list, correctly handle the case
  of changing it during iteration.
* When the parameters argument is a custom sequence, no longer
  override an exception raised in ``__len__()``.
(cherry picked from commit 0b419b7910)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
			
			
This commit is contained in:
		
							parent
							
								
									a9ba8ba9a7
								
							
						
					
					
						commit
						f76a3889d1
					
				
					 5 changed files with 34 additions and 3 deletions
				
			
		|  | @ -133,6 +133,19 @@ def CheckTypeMapUsage(self): | |||
|         con.execute("insert into foo(bar) values (5)") | ||||
|         con.execute(SELECT) | ||||
| 
 | ||||
|     def CheckBindMutatingList(self): | ||||
|         # Issue41662: Crash when mutate a list of parameters during iteration. | ||||
|         class X: | ||||
|             def __conform__(self, protocol): | ||||
|                 parameters.clear() | ||||
|                 return "..." | ||||
|         parameters = [X(), 0] | ||||
|         con = sqlite.connect(":memory:",detect_types=sqlite.PARSE_DECLTYPES) | ||||
|         con.execute("create table foo(bar X, baz integer)") | ||||
|         # Should not crash | ||||
|         with self.assertRaises(IndexError): | ||||
|             con.execute("insert into foo(bar, baz) values (?, ?)", parameters) | ||||
| 
 | ||||
|     def CheckErrorMsgDecodeError(self): | ||||
|         # When porting the module to Python 3.0, the error message about | ||||
|         # decoding errors disappeared. This verifies they're back again. | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)