-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
bpo-31843: sqlite3.connect() now accepts PathLike objects as database name #4299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8dd99cb
954615c
62a7d00
be022cf
ceb6de5
72e4cf7
4cef352
8b7f340
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*database* argument of sqlite3.connect() now accepts a | ||
:term:`path-like object`, instead of just a string. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,7 @@ static PyObject* module_connect(PyObject* self, PyObject* args, PyObject* | |
"check_same_thread", "factory", "cached_statements", "uri", | ||
NULL | ||
}; | ||
char* database; | ||
PyObject* database; | ||
int detect_types = 0; | ||
PyObject* isolation_level; | ||
PyObject* factory = NULL; | ||
|
@@ -66,7 +66,7 @@ static PyObject* module_connect(PyObject* self, PyObject* args, PyObject* | |
|
||
PyObject* result; | ||
|
||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|diOiOip", kwlist, | ||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|diOiOip", kwlist, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why the function checks arguments. Why not only relying on Connection constructor to check arguments? Either remove the whole code to parse arguments, or fix the reference leak: Py_DECREF(database); is needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Oops, it's not needed, you don't use PyUnicode_FSConverter, sorry. Your code is correct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Phaqui pointed me on IRC that the function contains a comment explaining that we have to parse all arguments to just extract the "factory" keyword argument... In that case, the code is ok. |
||
&database, &timeout, &detect_types, | ||
&isolation_level, &check_same_thread, | ||
&factory, &cached_statements, &uri)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to document the change. Something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done