diff options
| author | Guido van Rossum <guido@python.org> | 2007-11-06 21:34:58 +0000 | 
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 2007-11-06 21:34:58 +0000 | 
| commit | 98297ee7815939b124156e438b22bd652d67b5db (patch) | |
| tree | a9d239ebd87c73af2571ab48003984c4e18e27e5 /Modules/_sqlite | |
| parent | a19f80c6df2df5e8a5d0cff37131097835ef971e (diff) | |
| download | cpython-git-98297ee7815939b124156e438b22bd652d67b5db.tar.gz | |
Merging the py3k-pep3137 branch back into the py3k branch.
No detailed change log; just check out the change log for the py3k-pep3137
branch.  The most obvious changes:
  - str8 renamed to bytes (PyString at the C level);
  - bytes renamed to buffer (PyBytes at the C level);
  - PyString and PyUnicode are no longer compatible.
I.e. we now have an immutable bytes type and a mutable bytes type.
The behavior of PyString was modified quite a bit, to make it more
bytes-like.  Some changes are still on the to-do list.
Diffstat (limited to 'Modules/_sqlite')
| -rw-r--r-- | Modules/_sqlite/cache.c | 4 | ||||
| -rw-r--r-- | Modules/_sqlite/connection.c | 14 | ||||
| -rw-r--r-- | Modules/_sqlite/cursor.c | 16 | ||||
| -rw-r--r-- | Modules/_sqlite/module.c | 2 | ||||
| -rw-r--r-- | Modules/_sqlite/row.c | 2 | ||||
| -rw-r--r-- | Modules/_sqlite/statement.c | 7 | 
6 files changed, 17 insertions, 28 deletions
diff --git a/Modules/_sqlite/cache.c b/Modules/_sqlite/cache.c index 829c175366..2f50e6aca2 100644 --- a/Modules/_sqlite/cache.c +++ b/Modules/_sqlite/cache.c @@ -241,12 +241,12 @@ PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args)          if (!fmt_args) {              return NULL;          } -        template = PyString_FromString("%s <- %s ->%s\n"); +        template = PyUnicode_FromString("%s <- %s ->%s\n");          if (!template) {              Py_DECREF(fmt_args);              return NULL;          } -        display_str = PyString_Format(template, fmt_args); +        display_str = PyUnicode_Format(template, fmt_args);          Py_DECREF(template);          Py_DECREF(fmt_args);          if (!display_str) { diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 5f899e88ff..d4318deec0 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -425,8 +425,6 @@ void _pysqlite_set_result(sqlite3_context* context, PyObject* py_val)          sqlite3_result_int64(context, (PY_LONG_LONG)longval);      } else if (PyFloat_Check(py_val)) {          sqlite3_result_double(context, PyFloat_AsDouble(py_val)); -    } else if (PyString_Check(py_val)) { -        sqlite3_result_text(context, PyString_AsString(py_val), -1, SQLITE_TRANSIENT);      } else if (PyUnicode_Check(py_val)) {          sqlite3_result_text(context, PyUnicode_AsString(py_val), -1, SQLITE_TRANSIENT);      } else if (PyObject_CheckBuffer(py_val)) { @@ -467,7 +465,7 @@ PyObject* _pysqlite_build_py_params(sqlite3_context *context, int argc, sqlite3_                  break;              case SQLITE_TEXT:                  val_str = (const char*)sqlite3_value_text(cur_value); -                cur_py_value = PyUnicode_DecodeUTF8(val_str, strlen(val_str), NULL); +                cur_py_value = PyUnicode_FromString(val_str);                  /* TODO: have a way to show errors here */                  if (!cur_py_value) {                      PyErr_Clear(); @@ -477,7 +475,7 @@ PyObject* _pysqlite_build_py_params(sqlite3_context *context, int argc, sqlite3_                  break;              case SQLITE_BLOB:                  buflen = sqlite3_value_bytes(cur_value); -                cur_py_value = PyBytes_FromStringAndSize( +                cur_py_value = PyString_FromStringAndSize(                      sqlite3_value_blob(cur_value), buflen);                  break;              case SQLITE_NULL: @@ -1023,8 +1021,8 @@ pysqlite_collation_callback(          goto finally;      } -    string1 = PyString_FromStringAndSize((const char*)text1_data, text1_length); -    string2 = PyString_FromStringAndSize((const char*)text2_data, text2_length); +    string1 = PyUnicode_FromStringAndSize((const char*)text1_data, text1_length); +    string2 = PyUnicode_FromStringAndSize((const char*)text2_data, text2_length);      if (!string1 || !string2) {          goto finally; /* failed to allocate strings */ @@ -1093,7 +1091,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)          goto finally;      } -    chk = PyString_AsString(uppercase_name); +    chk = PyUnicode_AsString(uppercase_name);      while (*chk) {          if ((*chk >= '0' && *chk <= '9')           || (*chk >= 'A' && *chk <= 'Z') @@ -1118,7 +1116,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)      }      rc = sqlite3_create_collation(self->db, -                                  PyString_AsString(uppercase_name), +                                  PyUnicode_AsString(uppercase_name),                                    SQLITE_UTF8,                                    (callable != Py_None) ? callable : NULL,                                    (callable != Py_None) ? pysqlite_collation_callback : NULL); diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index c789fafb38..c51c92ede8 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -272,11 +272,7 @@ PyObject* pysqlite_unicode_from_string(const char* val_str, int optimize)          }      } -    if (is_ascii) { -        return PyString_FromString(val_str); -    } else { -        return PyUnicode_DecodeUTF8(val_str, strlen(val_str), NULL); -    } +    return PyUnicode_FromString(val_str);  }  /* @@ -379,7 +375,7 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self)              } else {                  /* coltype == SQLITE_BLOB */                  nbytes = sqlite3_column_bytes(self->statement->st, i); -                buffer = PyBytes_FromStringAndSize( +                buffer = PyString_FromStringAndSize(                      sqlite3_column_blob(self->statement->st, i), nbytes);                  if (!buffer) {                      break; @@ -436,8 +432,8 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*              return NULL;           } -        if (!PyString_Check(operation) && !PyUnicode_Check(operation)) { -            PyErr_SetString(PyExc_ValueError, "operation parameter must be str or unicode"); +        if (!PyUnicode_Check(operation)) { +            PyErr_SetString(PyExc_ValueError, "operation parameter must be str");              return NULL;          } @@ -458,8 +454,8 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*              return NULL;           } -        if (!PyString_Check(operation) && !PyUnicode_Check(operation)) { -            PyErr_SetString(PyExc_ValueError, "operation parameter must be str or unicode"); +        if (!PyUnicode_Check(operation)) { +            PyErr_SetString(PyExc_ValueError, "operation parameter must be str");              return NULL;          } diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c index 61ac0a1306..107d61a652 100644 --- a/Modules/_sqlite/module.c +++ b/Modules/_sqlite/module.c @@ -146,7 +146,7 @@ static PyObject* module_register_converter(PyObject* self, PyObject* args, PyObj      PyObject* callable;      PyObject* retval = NULL; -    if (!PyArg_ParseTuple(args, "SO", &orig_name, &callable)) { +    if (!PyArg_ParseTuple(args, "UO", &orig_name, &callable)) {          return NULL;      } diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c index 2f3ba69f10..dfb6363cd0 100644 --- a/Modules/_sqlite/row.c +++ b/Modules/_sqlite/row.c @@ -87,7 +87,7 @@ PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)          nitems = PyTuple_Size(self->description);          for (i = 0; i < nitems; i++) { -            compare_key = PyString_AsString(PyTuple_GET_ITEM(PyTuple_GET_ITEM(self->description, i), 0)); +            compare_key = PyUnicode_AsString(PyTuple_GET_ITEM(PyTuple_GET_ITEM(self->description, i), 0));              if (!compare_key) {                  return NULL;              } diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c index 1cc3cddd40..98cc68a853 100644 --- a/Modules/_sqlite/statement.c +++ b/Modules/_sqlite/statement.c @@ -105,15 +105,10 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec  #endif      } else if (PyFloat_Check(parameter)) {          rc = sqlite3_bind_double(self->st, pos, PyFloat_AsDouble(parameter)); -    } else if PyString_Check(parameter) { -        string = PyString_AsString(parameter); -        rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);      } else if PyUnicode_Check(parameter) { -        stringval = PyUnicode_AsUTF8String(parameter); -        string = PyBytes_AsString(stringval); +        string = PyUnicode_AsString(parameter);          rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT); -        Py_DECREF(stringval);      } else if (PyObject_CheckBuffer(parameter)) {          if (PyObject_AsCharBuffer(parameter, &buffer, &buflen) == 0) {              rc = sqlite3_bind_blob(self->st, pos, buffer, buflen, SQLITE_TRANSIENT);  | 
