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:
Daniele Varrazzo 2010-12-29 23:53:03 +01:00
parent 0a4eeb4e13
commit bc28cc8b00
2 changed files with 2 additions and 3 deletions

View File

@ -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) {

View File

@ -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 */