Visitar URL original
bpo-42064: Move `sqlite3` exceptions to global state, part 1 of 2 by erlend-aasland · Pull Request #26745 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20210624085840/https://github.com/python/cpython/pull/26745
Skip to content
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

bpo-42064: Move sqlite3 exceptions to global state, part 1 of 2 #26745

Merged
merged 9 commits into from Jun 23, 2021

Conversation

@erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented Jun 15, 2021 •

Also adds a test to verify the (borrowed) exceptions in sqlite3.Connection.

https://bugs.python.org/issue42064

Automerge-Triggered-By: GH:encukou

@erlend-aasland
Copy link
Contributor Author

@erlend-aasland erlend-aasland commented Jun 15, 2021

@encukou Whenever you have time, would you mind reviewing this as well? I've split this operation in two; moving all exceptions was too large a diff.

@erlend-aasland erlend-aasland changed the title bpo-42064: Move sqlite3 exceptions to global state, part 1 bpo-42064: Move sqlite3 exceptions to global state, part 1 of 2 Jun 15, 2021
@encukou
Copy link
Member

@encukou encukou commented Jun 16, 2021

Looks OK at first glance but I'll do a review next week (after 3.10 beta 3)

@erlend-aasland erlend-aasland force-pushed the erlend-aasland:sqlite-move-err/1 branch from 3df4ccc to 4fe9d98 Jun 22, 2021
@erlend-aasland
Copy link
Contributor Author

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

I just remembered that all the connection object keeps borrowed references to all the sqlite3 exception types; we should use that instead of the module state where possible. See 4fe9d98.

@erlend-aasland erlend-aasland requested a review from encukou Jun 22, 2021
@erlend-aasland erlend-aasland force-pushed the erlend-aasland:sqlite-move-err/1 branch from f36e9e6 to c935f31 Jun 23, 2021
@encukou
Copy link
Member

@encukou encukou commented Jun 23, 2021

I just remembered that all the connection object keeps borrowed references to all the sqlite3 exception types

I see the connection type is created with PyType_FromModuleAndSpec, so connections hold a reference to the module through their type. (So the module is kept alive and the connections can borrow from it safely).
But, borrowed references tend to be confusing – you always have to think about things like this, even in the future as changes made in seemingly unrelated parts.
Is it worth it to update them to strong references? Or just one strong reference to the module?

Copy link
Member

@encukou encukou left a comment

The changes themselves look OK!

@miss-islington miss-islington merged commit a50e283 into python:main Jun 23, 2021
12 checks passed
12 checks passed
@github-actions
Check for source changes
Details
@github-actions
Check if generated files are up to date
Details
@github-actions
Windows (x86)
Details
@github-actions
Windows (x64)
Details
@github-actions
macOS
Details
@github-actions
Ubuntu
Details
@github-actions
Ubuntu SSL tests with OpenSSL
Details
@github-actions
Address sanitizer Address sanitizer
Details
Azure Pipelines PR #20210623.20 succeeded
Details
@travis-ci
Travis CI - Pull Request Build Passed
Details
@bedevere-bot
bedevere/issue-number Issue number 42064 found
Details
@bedevere-bot
bedevere/news "skip news" label found
@erlend-aasland
Copy link
Contributor Author

@erlend-aasland erlend-aasland commented Jun 23, 2021

But, borrowed references tend to be confusing – you always have to think about things like this, even in the future as changes made in seemingly unrelated parts.
Is it worth it to update them to strong references? Or just one strong reference to the module?

Yes, I've thought about this. I think updating them to strong references is a good idea.

@erlend-aasland
Copy link
Contributor Author

@erlend-aasland erlend-aasland commented Jun 23, 2021

Thanks for reviewing, Petr!

@erlend-aasland erlend-aasland deleted the erlend-aasland:sqlite-move-err/1 branch Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants