@@ -76,6 +76,7 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
7676 };
7777
7878 char * database ;
79+ PyObject * database_obj ;
7980 int detect_types = 0 ;
8081 PyObject * isolation_level = NULL ;
8182 PyObject * factory = NULL ;
@@ -85,14 +86,16 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
8586 double timeout = 5.0 ;
8687 int rc ;
8788
88- if (!PyArg_ParseTupleAndKeywords (args , kwargs , "s |diOiOip" , kwlist ,
89- & database , & timeout , & detect_types ,
89+ if (!PyArg_ParseTupleAndKeywords (args , kwargs , "O& |diOiOip" , kwlist ,
90+ PyUnicode_FSConverter , & database_obj , & timeout , & detect_types ,
9091 & isolation_level , & check_same_thread ,
9192 & factory , & cached_statements , & uri ))
9293 {
9394 return -1 ;
9495 }
9596
97+ database = PyBytes_AsString (database_obj );
98+
9699 self -> initialized = 1 ;
97100
98101 self -> begin_statement = NULL ;
@@ -124,6 +127,8 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
124127#endif
125128 Py_END_ALLOW_THREADS
126129
130+ Py_DECREF (database_obj );
131+
127132 if (rc != SQLITE_OK ) {
128133 _pysqlite_seterror (self -> db , NULL );
129134 return -1 ;
0 commit comments