Imported Upstream version 0.4.4 upstream/0.4.4
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 18 Jul 2022 07:32:48 +0000 (16:32 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 18 Jul 2022 07:32:48 +0000 (16:32 +0900)
PKG-INFO
pysqlite3.egg-info/PKG-INFO
setup.py
src/blob.c
src/cache.c
src/connection.c
src/cursor.c

index 6be5a423d053891c0c86ed8022f9294ea2fc8334..a111d70edc082851591570605297d3d4ea0d10f0 100644 (file)
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 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
index 6be5a423d053891c0c86ed8022f9294ea2fc8334..a111d70edc082851591570605297d3d4ea0d10f0 100644 (file)
@@ -1,6 +1,6 @@
 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
index 4bda24381f951038850c218e0e103d2a4f7fda21..6a1d544517ec067ad1c6cd3b8fe1df02a9da0dc3 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,7 @@ from setuptools import Extension
 # 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)
index 3112132fa74ae4f5ebc5539e1b410055603bfa45..2d5a649aeb51aba6108a236b0874337003c09aa0 100644 (file)
@@ -208,12 +208,17 @@ PyObject* pysqlite_blob_write(pysqlite_Blob *self, PyObject *data)
         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);
 
@@ -257,19 +262,22 @@ PyObject* pysqlite_blob_seek(pysqlite_Blob *self, PyObject *args)
             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;
 }
 
 
@@ -332,7 +340,7 @@ static int pysqlite_blob_contains(pysqlite_Blob *self, PyObject *args)
 {
     if (pysqlite_check_blob(self)) {
         PyErr_SetString(PyExc_SystemError,
-                        "Blob don't support cotains operation");
+                        "Blob don't support contains operation");
     }
     return -1;
 }
@@ -407,11 +415,11 @@ static PyObject * pysqlite_blob_subscript(pysqlite_Blob *self, PyObject *item)
             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;
@@ -586,7 +594,7 @@ static int pysqlite_blob_ass_subscript(pysqlite_Blob *self, PyObject *item, PyOb
     }
     else {
         PyErr_SetString(PyExc_TypeError,
-                        "mmap indices must be integer");
+                        "Blob indices must be integer");
         return -1;
     }
 }
index 89ee894a40c19520c1bb2d525a16cbb8a9278311..1a8a8730199b4db25b8c3906ec141f4b4b204d50 100644 (file)
@@ -112,9 +112,8 @@ void pysqlite_cache_dealloc(pysqlite_Cache* self)
     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;
@@ -184,6 +183,9 @@ PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* args)
             }
         }
 
+        /* 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) {
index 46574432c99a1e3f1b10679ff72ea92f2605741c..77e7482fb5ac5e4a620677baa7954e94e483e6ad 100644 (file)
@@ -31,8 +31,6 @@
 #include "prepare_protocol.h"
 #include "util.h"
 
-#include "pythread.h"
-
 #define ACTION_FINALIZE 1
 #define ACTION_RESET 2
 
@@ -84,7 +82,7 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
         "vfs", NULL
     };
 
-    char* database;
+    const char* database;
     PyObject* database_obj;
     int detect_types = 0;
     PyObject* isolation_level = NULL;
@@ -1833,7 +1831,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
     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;
index 1941786069fd12992b18bc012992776e885d207d..4e801aec1594062a834eb4baf2f30f517a2d2937 100644 (file)
@@ -193,22 +193,30 @@ pysqlite_build_row_cast_map(pysqlite_Cursor* self)
 }
 
 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);
 }
 
 /*
@@ -370,6 +378,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* args)
     PyObject* result;
     int numcols;
     PyObject* descriptor;
+    PyObject* column_name;
     PyObject* second_argument = NULL;
     sqlite_int64 lastrowid;
 
@@ -536,7 +545,13 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* args)
                 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);