Metadata-Version: 1.1
Name: pysqlite3
-Version: 0.4.3
+Version: 0.4.4
Summary: DB-API 2.0 interface for Sqlite 3.x
Home-page: https://github.com/coleifer/pysqlite3
Author: Charles Leifer
Metadata-Version: 1.1
Name: pysqlite3
-Version: 0.4.3
+Version: 0.4.4
Summary: DB-API 2.0 interface for Sqlite 3.x
Home-page: https://github.com/coleifer/pysqlite3
Author: Charles Leifer
# If you need to change anything, it should be enough to change setup.cfg.
PACKAGE_NAME = 'pysqlite3'
-VERSION = '0.4.3'
+VERSION = '0.4.4'
# define sqlite sources
sources = [os.path.join('src', source)
return NULL;
}
- if (!pysqlite_check_blob(self)) {
+ if (data_buffer.len > self->length - self->offset) {
+ PyErr_SetString(PyExc_ValueError,
+ "data longer than blob length");
PyBuffer_Release(&data_buffer);
return NULL;
}
- /* TODO: throw better error on data bigger then blob. */
+ if (!pysqlite_check_blob(self)) {
+ PyBuffer_Release(&data_buffer);
+ return NULL;
+ }
rc = write_inner(self, data_buffer.buf, data_buffer.len, self->offset);
offset = self->length + offset;
break;
default:
- return PyErr_Format(PyExc_ValueError,
+ PyErr_SetString(PyExc_ValueError,
"from_what should be 0, 1 or 2");
+ return NULL;
}
if (offset < 0 || offset > self->length) {
- return PyErr_Format(PyExc_ValueError, "offset out of blob range");
+ PyErr_SetString(PyExc_ValueError, "offset out of blob range");
+ return NULL;
}
self->offset = offset;
Py_RETURN_NONE;
overflow:
- return PyErr_Format(PyExc_OverflowError, "seek offset result in overflow");
+ PyErr_SetString(PyExc_OverflowError, "seek offset result in overflow");
+ return NULL;
}
{
if (pysqlite_check_blob(self)) {
PyErr_SetString(PyExc_SystemError,
- "Blob don't support cotains operation");
+ "Blob don't support contains operation");
}
return -1;
}
return NULL;
}
- if (slicelen <= 0)
+ if (slicelen <= 0) {
return PyBytes_FromStringAndSize("", 0);
- else if (step == 1)
+ } else if (step == 1) {
return inner_read(self, slicelen, start);
- else {
+ } else {
char *result_buf = (char *)PyMem_Malloc(slicelen);
char *data_buff = NULL;
Py_ssize_t cur, i;
}
else {
PyErr_SetString(PyExc_TypeError,
- "mmap indices must be integer");
+ "Blob indices must be integer");
return -1;
}
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
-PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* args)
+PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* key)
{
- PyObject* key = args;
pysqlite_Node* node;
pysqlite_Node* ptr;
PyObject* data;
}
}
+ /* We cannot replace this by PyObject_CallOneArg() since
+ * PyObject_CallFunction() has a special case when using a
+ * single tuple as argument. */
data = PyObject_CallFunction(self->factory, "O", key);
if (!data) {
#include "prepare_protocol.h"
#include "util.h"
-#include "pythread.h"
-
#define ACTION_FINALIZE 1
#define ACTION_RESET 2
"vfs", NULL
};
- char* database;
+ const char* database;
PyObject* database_obj;
int detect_types = 0;
PyObject* isolation_level = NULL;
const char *uppercase_name_str;
int rc;
unsigned int kind;
- void *data;
+ const void *data;
if (!pysqlite_check_thread(self) || !pysqlite_check_connection(self)) {
goto finally;
}
static PyObject *
-_pysqlite_build_column_name(const char* colname)
+_pysqlite_build_column_name(pysqlite_Cursor *self, const char *colname)
{
const char* pos;
+ Py_ssize_t len;
if (!colname) {
Py_RETURN_NONE;
}
- for (pos = colname;; pos++) {
- if (*pos == 0 || *pos == '[') {
- if ((*pos == '[') && (pos > colname) && (*(pos-1) == ' ')) {
- pos--;
+ if (self->connection->detect_types & PARSE_COLNAMES) {
+ for (pos = colname; *pos; pos++) {
+ if (*pos == '[') {
+ if ((pos != colname) && (*(pos-1) == ' ')) {
+ pos--;
+ }
+ break;
}
- return PyUnicode_FromStringAndSize(colname, pos - colname);
}
+ len = pos - colname;
+ }
+ else {
+ len = strlen(colname);
}
+ return PyUnicode_FromStringAndSize(colname, len);
}
/*
PyObject* result;
int numcols;
PyObject* descriptor;
+ PyObject* column_name;
PyObject* second_argument = NULL;
sqlite_int64 lastrowid;
if (!descriptor) {
goto error;
}
- PyTuple_SetItem(descriptor, 0, _pysqlite_build_column_name(sqlite3_column_name(self->statement->st, i)));
+ column_name = _pysqlite_build_column_name(self,
+ sqlite3_column_name(self->statement->st, i));
+ if (!column_name) {
+ Py_DECREF(descriptor);
+ goto error;
+ }
+ PyTuple_SetItem(descriptor, 0, column_name);
Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 1, Py_None);
Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 2, Py_None);
Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 3, Py_None);