mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	 287b84de93
			
		
	
	
		287b84de93
		
	
	
	
	
		
			
			The sqlit3.Connection object doesn't call its close() method when it's used as a context manager.
		
			
				
	
	
		
			13 lines
		
	
	
	
		
			254 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			13 lines
		
	
	
	
		
			254 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| import sqlite3
 | |
| import hashlib
 | |
| 
 | |
| def md5sum(t):
 | |
|     return hashlib.md5(t).hexdigest()
 | |
| 
 | |
| con = sqlite3.connect(":memory:")
 | |
| con.create_function("md5", 1, md5sum)
 | |
| cur = con.cursor()
 | |
| cur.execute("select md5(?)", (b"foo",))
 | |
| print(cur.fetchone()[0])
 | |
| 
 | |
| con.close()
 |