-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-40956: Convert sqlite3.connect and sqlite3.Connection.__init__ to AC #24421
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 15 commits
8192606
b72a29c
d361aeb
a861358
1ccf5e5
07164cb
a1e88c9
4977d78
1b2720f
c7cd9ee
39ed36b
754fdc6
e59af3b
ad345e0
af0fc7e
98f1a9d
89926af
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 @@ | ||
Use Argument Clinic in :mod:`sqlite3`. Patches by Erlend E. Aasland. |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -79,40 +79,34 @@ new_statement_cache(pysqlite_Connection *self, int maxsize) | |||||||||
return res; | ||||||||||
} | ||||||||||
|
||||||||||
/*[clinic input] | ||||||||||
_sqlite3.Connection.__init__ as pysqlite_connection_init | ||||||||||
|
||||||||||
database as database_obj: object(converter='PyUnicode_FSConverter') | ||||||||||
timeout: double = 5.0 | ||||||||||
detect_types: int = 0 | ||||||||||
isolation_level: object = NULL | ||||||||||
check_same_thread: bool(accept={int}) = True | ||||||||||
factory: object(c_default='(PyObject*)clinic_state()->ConnectionType') = ConnectionType | ||||||||||
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. Hummmm, i don't fully get how this is preserving the state as before. Seems that the previous code didn't have a default for factory and used NULL as the c default. Could you briefly explain how this default is preserving previous behaviour? 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. Sure :) This is the current code: cpython/Modules/_sqlite/module.c Lines 92 to 95 in 1d10bf0
In practice, the 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. Oh, I see. Is other code using this branch in 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.
Not in the stdlib (except for some tests in the test suite), but I guess it's used in the wild. Personally, I would not have added this feature in the first place.
That's kind of what we're doing no with the default AC argument, right? |
||||||||||
cached_statements: int = 128 | ||||||||||
uri: bool = False | ||||||||||
[clinic start generated code]*/ | ||||||||||
|
||||||||||
static int | ||||||||||
pysqlite_connection_init(pysqlite_Connection *self, PyObject *args, | ||||||||||
PyObject *kwargs) | ||||||||||
pysqlite_connection_init_impl(pysqlite_Connection *self, | ||||||||||
PyObject *database_obj, double timeout, | ||||||||||
int detect_types, PyObject *isolation_level, | ||||||||||
int check_same_thread, PyObject *factory, | ||||||||||
int cached_statements, int uri) | ||||||||||
/*[clinic end generated code: output=dc19df1c0e2b7b77 input=aa1f21bf12fe907a]*/ | ||||||||||
{ | ||||||||||
static char *kwlist[] = { | ||||||||||
"database", "timeout", "detect_types", "isolation_level", | ||||||||||
"check_same_thread", "factory", "cached_statements", "uri", | ||||||||||
NULL | ||||||||||
}; | ||||||||||
|
||||||||||
const char* database; | ||||||||||
PyObject* database_obj; | ||||||||||
int detect_types = 0; | ||||||||||
PyObject* isolation_level = NULL; | ||||||||||
PyObject* factory = NULL; | ||||||||||
int check_same_thread = 1; | ||||||||||
int cached_statements = 128; | ||||||||||
int uri = 0; | ||||||||||
double timeout = 5.0; | ||||||||||
int rc; | ||||||||||
|
||||||||||
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; | ||||||||||
} | ||||||||||
|
||||||||||
if (PySys_Audit("sqlite3.connect", "O", database_obj) < 0) { | ||||||||||
return -1; | ||||||||||
} | ||||||||||
|
||||||||||
database = PyBytes_AsString(database_obj); | ||||||||||
const char *database = PyBytes_AsString(database_obj); | ||||||||||
|
||||||||||
self->initialized = 1; | ||||||||||
|
||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.