mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-31843: sqlite3.connect() now accepts PathLike objects as database name (#4299)
This commit is contained in:
parent
edb13ae48c
commit
a22a127458
5 changed files with 32 additions and 7 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue