summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/connection.c
diff options
context:
space:
mode:
authorAnders Lorentsen <Phaqui@gmail.com>2017-11-07 00:47:43 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-11-07 00:47:43 (GMT)
commita22a127458d75b9b7e65e058f5db5ff705df5696 (patch)
tree02671d0bdaea01716305c713cc3a67433318aed2 /Modules/_sqlite/connection.c
parentedb13ae48c17210fa4b2d40a6833ca09db5c121b (diff)
downloadcpython-a22a127458d75b9b7e65e058f5db5ff705df5696.zip
cpython-a22a127458d75b9b7e65e058f5db5ff705df5696.tar.gz
cpython-a22a127458d75b9b7e65e058f5db5ff705df5696.tar.bz2
bpo-31843: sqlite3.connect() now accepts PathLike objects as database name (#4299)
Diffstat (limited to 'Modules/_sqlite/connection.c')
-rw-r--r--Modules/_sqlite/connection.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 70e56aa..57eee2d 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -76,6 +76,7 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
};
char* database;
+ PyObject* database_obj;
int detect_types = 0;
PyObject* isolation_level = NULL;
PyObject* factory = NULL;
@@ -85,14 +86,16 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
double timeout = 5.0;
int rc;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|diOiOip", kwlist,
- &database, &timeout, &detect_types,
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|diOiOip", kwlist,
+ PyUnicode_FSConverter, &database_obj, &timeout, &detect_types,
&isolation_level, &check_same_thread,
&factory, &cached_statements, &uri))
{
return -1;
}
+ database = PyBytes_AsString(database_obj);
+
self->initialized = 1;
self->begin_statement = NULL;
@@ -124,6 +127,8 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
#endif
Py_END_ALLOW_THREADS
+ Py_DECREF(database_obj);
+
if (rc != SQLITE_OK) {
_pysqlite_seterror(self->db, NULL);
return -1;