Skip to content

bpo-1635741: _sqlite3 uses PyModule_AddObjectRef #23148

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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review comment: Use intermingled variable declarations
  • Loading branch information
Erlend E. Aasland committed Nov 4, 2020
commit 590d11df2094c3c29b8267a32b280ccc3e16a8e4
7 changes: 2 additions & 5 deletions Modules/_sqlite/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,12 @@ pysqlite_adapt_impl(PyObject *module, PyObject *obj, PyObject *proto,

static int converters_init(PyObject* module)
{
int res;

_pysqlite_converters = PyDict_New();
if (!_pysqlite_converters) {
return -1;
}

res = PyModule_AddObjectRef(module, "converters", _pysqlite_converters);
int res = PyModule_AddObjectRef(module, "converters", _pysqlite_converters);
Py_DECREF(_pysqlite_converters);

return res;
Expand Down Expand Up @@ -374,7 +372,6 @@ do { \
PyMODINIT_FUNC PyInit__sqlite3(void)
{
PyObject *module;
int res;

if (sqlite3_libversion_number() < 3007003) {
PyErr_SetString(PyExc_ImportError, MODULE_NAME ": SQLite 3.7.3 or higher required");
Expand Down Expand Up @@ -422,7 +419,7 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
Now OptimizedUnicode is an alias for str, so it has no
effect. */
Py_INCREF((PyObject*)&PyUnicode_Type);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call looks like a ref leak.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the (now) useless INCREF/DECREF dance.

Copy link
Contributor Author

@erlend-aasland erlend-aasland Nov 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it; thanks!

res = PyModule_AddObjectRef(module, "OptimizedUnicode", (PyObject*)&PyUnicode_Type);
int res = PyModule_AddObjectRef(module, "OptimizedUnicode", (PyObject*)&PyUnicode_Type);
Py_DECREF((PyObject*)&PyUnicode_Type);
if (res == -1) {
goto error;
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy