This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: refleaks when calling sqlite3.Connection.__init__() more than once
Type: resource usage Stage: resolved
Components: Extension Modules Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Oren Milman, vstinner
Priority: normal Keywords: patch

Created on 2017-10-09 20:32 by Oren Milman, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3944 merged Oren Milman, 2017-10-10 14:19
Messages (5)
msg303997 - (view) Author: Oren Milman (Oren Milman) * Date: 2017-10-09 20:32
The following code causes refleaks:
import sqlite3
connection = sqlite3.Connection.__new__(sqlite3.Connection)
connection.__init__('foo')
connection.__init__('foo')

This is because pysqlite_connection_init() (in Modules/_sqlite/connection.c)
doesn't decref (if needed) before assigning to various fields of `self`.

I would open a PR to fix this soon.
msg303999 - (view) Author: Oren Milman (Oren Milman) * Date: 2017-10-09 20:52
Ah, here also there are crashes when calling methods of uninitialized connection objects.

Should i fix this as part of this issue, or open another one?
msg304048 - (view) Author: Oren Milman (Oren Milman) * Date: 2017-10-10 14:39
(opened bpo-31746 for the crashes i mentioned)
msg304071 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-10 19:27
New changeset 93c5a5df8ea118f6e4a153a7c8cccd65a5ff8bff by Victor Stinner (Oren Milman) in branch 'master':
bpo-31740: Prevent refleaks when sqlite3.Connection.__init__() is called more than once (GH-3944)
https://github.com/python/cpython/commit/93c5a5df8ea118f6e4a153a7c8cccd65a5ff8bff
msg304072 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-10 19:35
Oren Milman: thanks for your contribution! I merged your PR.

I don't consider that such corner case requires to backport the change to Python 2.7 and 3.6.
History
Date User Action Args
2022-04-11 14:58:53adminsetgithub: 75921
2017-10-10 19:35:17vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg304072

stage: patch review -> resolved
2017-10-10 19:27:48vstinnersetnosy: + vstinner
messages: + msg304071
2017-10-10 14:39:39Oren Milmansetmessages: + msg304048
2017-10-10 14:19:07Oren Milmansetkeywords: + patch
stage: patch review
pull_requests: + pull_request3917
2017-10-09 20:52:28Oren Milmansetmessages: + msg303999
2017-10-09 20:32:17Oren Milmancreate