Mercurial > cpython-lru_cache-weakref
diff Modules/_sqlite/cursor.c @ 47527:52294af4b663 legacy-trunk
This reverts r63675 based on the discussion in this thread:
http://mail.python.org/pipermail/python-dev/2008-June/079988.html
Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names
in the spirit of 3.0 are available via a #define only. See the email thread.
| author | Gregory P. Smith <greg@mad-scientist.com> |
|---|---|
| date | Mon, 09 Jun 2008 04:58:54 +0000 |
| parents | 0156c336e6b3 |
| children | afe8d515bfe2 |
line wrap: on
line diff
--- a/Modules/_sqlite/cursor.c Mon Jun 09 01:28:30 2008 +0000 +++ b/Modules/_sqlite/cursor.c Mon Jun 09 04:58:54 2008 +0000 @@ -178,7 +178,7 @@ if (*pos == '[') { type_start = pos + 1; } else if (*pos == ']' && type_start != (const char*)-1) { - key = PyBytes_FromStringAndSize(type_start, pos - type_start); + key = PyString_FromStringAndSize(type_start, pos - type_start); if (!key) { /* creating a string failed, but it is too complicated * to propagate the error here, we just assume there is @@ -203,7 +203,7 @@ * 'NUMBER(10)' to be treated as 'NUMBER', for example. * In other words, it will work as people expect it to work.*/ if (*pos == ' ' || *pos == '(' || *pos == 0) { - py_decltype = PyBytes_FromStringAndSize(decltype, pos - decltype); + py_decltype = PyString_FromStringAndSize(decltype, pos - decltype); if (!py_decltype) { return -1; } @@ -248,7 +248,7 @@ if ((*pos == '[') && (pos > colname) && (*(pos-1) == ' ')) { pos--; } - return PyBytes_FromStringAndSize(colname, pos - colname); + return PyString_FromStringAndSize(colname, pos - colname); } } } @@ -273,7 +273,7 @@ } if (is_ascii) { - return PyBytes_FromString(val_str); + return PyString_FromString(val_str); } else { return PyUnicode_DecodeUTF8(val_str, strlen(val_str), NULL); } @@ -327,7 +327,7 @@ Py_INCREF(Py_None); converted = Py_None; } else { - item = PyBytes_FromStringAndSize(val_str, nbytes); + item = PyString_FromStringAndSize(val_str, nbytes); if (!item) { return NULL; } @@ -370,8 +370,8 @@ colname , val_str); PyErr_SetString(pysqlite_OperationalError, buf); } - } else if (self->connection->text_factory == (PyObject*)&PyBytes_Type) { - converted = PyBytes_FromString(val_str); + } else if (self->connection->text_factory == (PyObject*)&PyString_Type) { + converted = PyString_FromString(val_str); } else { converted = PyObject_CallFunction(self->connection->text_factory, "s", val_str); } @@ -442,7 +442,7 @@ return NULL; } - if (!PyBytes_Check(operation) && !PyUnicode_Check(operation)) { + if (!PyString_Check(operation) && !PyUnicode_Check(operation)) { PyErr_SetString(PyExc_ValueError, "operation parameter must be str or unicode"); return NULL; } @@ -464,7 +464,7 @@ return NULL; } - if (!PyBytes_Check(operation) && !PyUnicode_Check(operation)) { + if (!PyString_Check(operation) && !PyUnicode_Check(operation)) { PyErr_SetString(PyExc_ValueError, "operation parameter must be str or unicode"); return NULL; } @@ -499,15 +499,15 @@ rc = pysqlite_statement_reset(self->statement); } - if (PyBytes_Check(operation)) { - operation_cstr = PyBytes_AsString(operation); + if (PyString_Check(operation)) { + operation_cstr = PyString_AsString(operation); } else { operation_bytestr = PyUnicode_AsUTF8String(operation); if (!operation_bytestr) { goto error; } - operation_cstr = PyBytes_AsString(operation_bytestr); + operation_cstr = PyString_AsString(operation_bytestr); } /* reset description and rowcount */ @@ -764,15 +764,15 @@ return NULL; } - if (PyBytes_Check(script_obj)) { - script_cstr = PyBytes_AsString(script_obj); + if (PyString_Check(script_obj)) { + script_cstr = PyString_AsString(script_obj); } else if (PyUnicode_Check(script_obj)) { script_str = PyUnicode_AsUTF8String(script_obj); if (!script_str) { return NULL; } - script_cstr = PyBytes_AsString(script_str); + script_cstr = PyString_AsString(script_str); } else { PyErr_SetString(PyExc_ValueError, "script argument must be unicode or string."); return NULL;
