Skip to content

bpo-45126: Ensure sqlite3.Connection is unusable if __init__ fails #29160

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

Closed

Conversation

erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented Oct 22, 2021

If sqlite3.Connection.__init__() fails, explicitly set self->db and
self->initialized to NULL/zero.

https://bugs.python.org/issue45126

Erlend E. Aasland added 2 commits October 22, 2021 14:55
If sqlite3.Connection.__init__() fails, always leave it with self->db
and self->initialized set to NULL/zero.
@erlend-aasland
Copy link
Contributor Author

Not sure if it is a good idea to include a NEWS entry here. We don't want to encourage re-init for connection objects.

@erlend-aasland
Copy link
Contributor Author

@erlend-aasland
Copy link
Contributor Author

FYI, the exception set by _pysqlite_seterror after a failed sqlite3_open_v2 may be incorrect. We should use the result code from sqlite3_open_v2 when setting that exception, instead of fetching the error code from the database pointer. I fix that in a separate PR.

@erlend-aasland
Copy link
Contributor Author

This PR was a little bit rushed; this approach is totally wrong; sorry for the noise. GH-28227 is a much better approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants