mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-10-30 23:37:29 +03:00 
			
		
		
		
	Use unicode keys as strings in Py3.
This fixes pyformat style argument passing. Unicode and bytes don't compare equal (even if they hash the same).
This commit is contained in:
		
							parent
							
								
									0a4eeb4e13
								
							
						
					
					
						commit
						bc28cc8b00
					
				|  | @ -207,8 +207,7 @@ PyBytes_Format(PyObject *format, PyObject *args) | |||
|                                "incomplete format key"); | ||||
|                     goto error; | ||||
|                 } | ||||
|                 key = PyBytes_FromStringAndSize(keystart, | ||||
|                                                  keylen); | ||||
|                 key = PyUnicode_FromStringAndSize(keystart, keylen); | ||||
|                 if (key == NULL) | ||||
|                     goto error; | ||||
|                 if (args_owned) { | ||||
|  |  | |||
|  | @ -116,7 +116,7 @@ _mogrify(PyObject *var, PyObject *fmt, connectionObject *conn, PyObject **new) | |||
|             for (d = c + 2; *d && *d != ')'; d++); | ||||
| 
 | ||||
|             if (*d == ')') { | ||||
|                 key = Bytes_FromStringAndSize(c+2, (Py_ssize_t) (d-c-2)); | ||||
|                 key = Text_FromUTF8AndSize(c+2, (Py_ssize_t) (d-c-2)); | ||||
|                 value = PyObject_GetItem(var, key); | ||||
|                 /* key has refcnt 1, value the original value + 1 */ | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user