mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-18 18:00:35 +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");
|
"incomplete format key");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
key = PyBytes_FromStringAndSize(keystart,
|
key = PyUnicode_FromStringAndSize(keystart, keylen);
|
||||||
keylen);
|
|
||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
if (args_owned) {
|
if (args_owned) {
|
||||||
|
|
|
@ -116,7 +116,7 @@ _mogrify(PyObject *var, PyObject *fmt, connectionObject *conn, PyObject **new)
|
||||||
for (d = c + 2; *d && *d != ')'; d++);
|
for (d = c + 2; *d && *d != ')'; d++);
|
||||||
|
|
||||||
if (*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);
|
value = PyObject_GetItem(var, key);
|
||||||
/* key has refcnt 1, value the original value + 1 */
|
/* key has refcnt 1, value the original value + 1 */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user