bpo-31843: sqlite3.connect() now accepts PathLike objects as database name (#4299)

This commit is contained in:
Anders Lorentsen 2017-11-07 01:47:43 +01:00 committed by Victor Stinner
parent edb13ae48c
commit a22a127458
5 changed files with 32 additions and 7 deletions

View file

@ -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;