This commit is contained in:
INADA Naoki
2014-04-17 19:50:42 +09:00
parent acc984c247
commit 9cdef719a6

View File

@ -265,7 +265,7 @@ static PyObject *_mysql_server_init(
for (i=0; i< cmd_argc; i++) { for (i=0; i< cmd_argc; i++) {
item = PySequence_GetItem(cmd_args, i); item = PySequence_GetItem(cmd_args, i);
#ifdef IS_PY3K #ifdef IS_PY3K
s = PyUnicode_AS_DATA(item); s = PyUnicode_AsUTF8(item);
#else #else
s = PyString_AsString(item); s = PyString_AsString(item);
#endif #endif
@ -295,7 +295,7 @@ static PyObject *_mysql_server_init(
for (i=0; i< groupc; i++) { for (i=0; i< groupc; i++) {
item = PySequence_GetItem(groups, i); item = PySequence_GetItem(groups, i);
#ifdef IS_PY3K #ifdef IS_PY3K
s = PyUnicode_AS_DATA(item); s = PyUnicode_AsUTF8(item);
#else #else
s = PyString_AsString(item); s = PyString_AsString(item);
#endif #endif
@ -578,7 +578,7 @@ _mysql_ConnectionObject_Initialize(
#ifdef IS_PY3K #ifdef IS_PY3K
#define _stringsuck(d,t,s) {t=PyMapping_GetItemString(s,#d);\ #define _stringsuck(d,t,s) {t=PyMapping_GetItemString(s,#d);\
if(t){d=PyUnicode_AS_DATA(t);Py_DECREF(t);}\ if(t){d=PyUnicode_AsUTF8(t);Py_DECREF(t);}\
PyErr_Clear();} PyErr_Clear();}
#else #else
#define _stringsuck(d,t,s) {t=PyMapping_GetItemString(s,#d);\ #define _stringsuck(d,t,s) {t=PyMapping_GetItemString(s,#d);\
@ -1334,19 +1334,16 @@ _mysql_field_to_python(
{ {
PyObject *v; PyObject *v;
if (rowitem) { if (rowitem) {
if (converter != Py_None) if (converter != Py_None) {
v = PyObject_CallFunction(converter, v = PyObject_CallFunction(converter,
"s#", "s#",
rowitem, rowitem,
(int)length); (int)length);
else } else {
#ifdef IS_PY3K // TODO: Should we decode here on Python 3?
v = PyUnicode_FromStringAndSize(rowitem, v = PyBytes_FromStringAndSize(rowitem,
(int)length); (int)length);
#else }
v = PyString_FromStringAndSize(rowitem,
(int)length);
#endif
if (!v) if (!v)
return NULL; return NULL;
} else { } else {