Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-42972: Fully implement GC protocol for sqlite3 heap types#26104
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
14 commits Select commit Hold shift + click to select a range
6ece632 sqlite.Connection type now implements GC protocol
8660609 sqlite.Cursor type now implements GC protocol
13bc519 sqlite.Row type now implements GC protocol
4519017 sqlite.PrepareProtocol type now implements GC protocol
20da088 sqlite.Statement type now implements GC protocol
ca870ac sqlite3.Cache and sqlite3.Node types now implements GC protocol
f5d9873 Remove unneeded self->db = NULL
34928ed Get rid of unneeded cast in cursor_dealloc
590ff8e Address review: visit node->key, node->data, and con->isolation_level
b080ff7 Harden cache clear
2bcfa29 Normalize connection_dealloc naming
f8eb733 Address review: visit row PyObjects for consistency
ab4c6e6 Normalize statement dealloc naming
926787d Clear sqlite3 stmt resources in stmt_clear()
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -225,28 +225,51 @@ pysqlite_do_all_statements(pysqlite_Connection *self, int action, | ||
| } | ||
| } | ||
| static int | ||
| connection_traverse(pysqlite_Connection *self, visitproc visit, void *arg) | ||
| { | ||
| Py_VISIT(self->statement_cache); | ||
erlend-aasland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| Py_VISIT(self->isolation_level); | ||
| Py_VISIT(self->function_pinboard_trace_callback); | ||
| Py_VISIT(self->function_pinboard_progress_handler); | ||
| Py_VISIT(self->function_pinboard_authorizer_cb); | ||
| Py_VISIT(self->row_factory); | ||
| Py_VISIT(self->text_factory); | ||
| Py_VISIT(self->collations); | ||
| Py_VISIT(self->statements); | ||
| Py_VISIT(self->cursors); | ||
| Py_VISIT(Py_TYPE(self)); | ||
| return 0; | ||
| } | ||
| static int | ||
| connection_clear(pysqlite_Connection *self) | ||
| { | ||
| Py_CLEAR(self->statement_cache); | ||
| Py_CLEAR(self->isolation_level); | ||
| Py_CLEAR(self->function_pinboard_trace_callback); | ||
| Py_CLEAR(self->function_pinboard_progress_handler); | ||
| Py_CLEAR(self->function_pinboard_authorizer_cb); | ||
| Py_CLEAR(self->row_factory); | ||
| Py_CLEAR(self->text_factory); | ||
| Py_CLEAR(self->collations); | ||
| Py_CLEAR(self->statements); | ||
| Py_CLEAR(self->cursors); | ||
| return 0; | ||
| } | ||
| static void | ||
| pysqlite_connection_dealloc(pysqlite_Connection *self) | ||
| connection_dealloc(pysqlite_Connection *self) | ||
| { | ||
| PyTypeObject *tp = Py_TYPE(self); | ||
| Py_XDECREF(self->statement_cache); | ||
| PyObject_GC_UnTrack(self); | ||
| tp->tp_clear((PyObject *)self); | ||
| /* Clean up if user has not called .close() explicitly. */ | ||
| if (self->db){ | ||
| sqlite3_close_v2(self->db); | ||
| } | ||
| Py_XDECREF(self->isolation_level); | ||
| Py_XDECREF(self->function_pinboard_trace_callback); | ||
| Py_XDECREF(self->function_pinboard_progress_handler); | ||
| Py_XDECREF(self->function_pinboard_authorizer_cb); | ||
| Py_XDECREF(self->row_factory); | ||
| Py_XDECREF(self->text_factory); | ||
| Py_XDECREF(self->collations); | ||
| Py_XDECREF(self->statements); | ||
| Py_XDECREF(self->cursors); | ||
| tp->tp_free(self); | ||
| Py_DECREF(tp); | ||
| } | ||
| @@ -1328,7 +1351,7 @@ pysqlite_connection_call(pysqlite_Connection *self, PyObject *args, | ||
| _pysqlite_drop_unused_statement_references(self); | ||
| statement = PyObject_New(pysqlite_Statement, pysqlite_StatementType); | ||
| statement = PyObject_GC_New(pysqlite_Statement, pysqlite_StatementType); | ||
| if (!statement){ | ||
| return NULL; | ||
| } | ||
| @@ -1909,21 +1932,22 @@ static struct PyMemberDef connection_members[] = | ||
| }; | ||
| static PyType_Slot connection_slots[] ={ | ||
| {Py_tp_dealloc, pysqlite_connection_dealloc}, | ||
| {Py_tp_dealloc, connection_dealloc}, | ||
| {Py_tp_doc, (void *)connection_doc}, | ||
| {Py_tp_methods, connection_methods}, | ||
| {Py_tp_members, connection_members}, | ||
| {Py_tp_getset, connection_getset}, | ||
| {Py_tp_new, PyType_GenericNew}, | ||
| {Py_tp_init, pysqlite_connection_init}, | ||
| {Py_tp_call, pysqlite_connection_call}, | ||
| {Py_tp_traverse, connection_traverse}, | ||
| {Py_tp_clear, connection_clear}, | ||
| {0, NULL}, | ||
| }; | ||
| static PyType_Spec connection_spec ={ | ||
| .name = MODULE_NAME ".Connection", | ||
| .basicsize = sizeof(pysqlite_Connection), | ||
| .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, | ||
| .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, | ||
| .slots = connection_slots, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -30,26 +30,33 @@ pysqlite_prepare_protocol_init(pysqlite_PrepareProtocol *self, PyObject *args, | ||
| return 0; | ||
| } | ||
| static int | ||
| pysqlite_prepare_protocol_traverse(PyObject *self, visitproc visit, void *arg) | ||
erlend-aasland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| { | ||
| Py_VISIT(Py_TYPE(self)); | ||
| return 0; | ||
| } | ||
| static void | ||
| pysqlite_prepare_protocol_dealloc(pysqlite_PrepareProtocol *self) | ||
| { | ||
| PyTypeObject *tp = Py_TYPE(self); | ||
| PyObject_GC_UnTrack(self); | ||
| tp->tp_free(self); | ||
| Py_DECREF(tp); | ||
| } | ||
| static PyType_Slot type_slots[] ={ | ||
| {Py_tp_dealloc, pysqlite_prepare_protocol_dealloc}, | ||
| {Py_tp_new, PyType_GenericNew}, | ||
| {Py_tp_init, pysqlite_prepare_protocol_init}, | ||
| {Py_tp_traverse, pysqlite_prepare_protocol_traverse}, | ||
| {0, NULL}, | ||
| }; | ||
| static PyType_Spec type_spec ={ | ||
| .name = MODULE_NAME ".PrepareProtocol", | ||
| .basicsize = sizeof(pysqlite_PrepareProtocol), | ||
| .flags = Py_TPFLAGS_DEFAULT, | ||
| .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, | ||
| .slots = type_slots, | ||
| }; | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.