GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-106104: Use public weakref APIs in sqlite3 by erlend-aasland · Pull Request #106105 · python/cpython

Conversation

@erlend-aasland

@erlend-aasland erlend-aasland commented Jun 26, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

The sqlite3 extension module should be built using the public API, so
we're removing the Py_BUILD_CORE_MODULE define that was introduced as
part of the gh-105927 changes.

  • Issue: The sqlite3 module should not be built as a core module #106104

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@erlend-aasland
pythongh-106104: Use public weakref APIs in sqlite3
43cbf83
The sqlite3 extension module should be built using the public API, so
we're removing the Py_BUILD_CORE_MODULE define that was introduced as
part of the pythongh-105927 changes.
@erlend-aasland
erlend-aasland requested a review from berkerpeksag as a code owner June 26, 2023 13:03
@erlend-aasland
erlend-aasland requested a review from vstinner June 26, 2023 13:03
@bedevere-bot bedevere-bot added the awaiting core review label Jun 26, 2023
@bedevere-bot bedevere-bot mentioned this pull request Jun 26, 2023
The sqlite3 module should not be built as a core module #106104
Closed
@erlend-aasland erlend-aasland added the skip news label Jun 26, 2023
@erlend-aasland erlend-aasland linked an issue Jun 26, 2023 that may be closed by this pull request
The sqlite3 module should not be built as a core module #106104
Closed
@erlend-aasland
Intermingled decls
af0ced9
vstinner
vstinner reviewed Jun 27, 2023
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Is it an issue to use the internal C API?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Modules/_sqlite/blob.c
PyObject *blob = _PyWeakref_GET_REF(weakref);
if (blob == NULL) {
if (!PyWeakref_Check(weakref)) {
continue;

@vstinner vstinner Jun 27, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Is it possible that blobs contain something which is not a weakref?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Modules/_sqlite/blob.c
Py_DECREF(blob);
PyObject *blob;
if (PyWeakref_GetRef(weakref, &blob) < 0) {
PyErr_WriteUnraisable((PyObject *)self);

@vstinner vstinner Jun 27, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We should make _PyErr_WriteUnraisableMsg() public, since this one logs a message which is hard to get, it gives no context.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@erlend-aasland

erlend-aasland commented Jun 27, 2023

Copy link
Copy Markdown
Contributor Author

Is it an issue to use the internal C API?

Not a big issue, but historically, the sqlite3 extension module has been implemented (mostly) using public API. See also:

  • [C API] Convert a few stdlib extensions to the limited C API (PEP 384) #85283
  • bpo-46541: Replace _Py_IDENTIFIER with _Py_ID in sqlite3 #31351 (comment)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland

erlend-aasland commented Jun 27, 2023

Copy link
Copy Markdown
Contributor Author

Related: I see that _ssl also accidentally got Py_BUILD_CORE_MODULE defined in 46a3190 ;)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jun 27, 2023

Copy link
Copy Markdown
Member

Related: I see that _ssl also accidentally got Py_BUILD_CORE_MODULE defined in 46a3190 ;)

How is it an issue to use the internal C API? The internal C API is written for best performances thanks to inlining when you control the argument types.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner approved these changes Jul 12, 2023
View reviewed changes

@vstinner vstinner left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM.

Well, if you don't want to use the internal C API in sqlite3, yep, the change is good. But warning: I made other sqlite3 changes in the meanwhile to use more internal APIs!?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Modules/_sqlite/connection.c
PyErr_WriteUnraisable((PyObject *)self);
continue;
}
if (item) {

@vstinner vstinner Jul 12, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I suggest if (!item) continue; to avoid one indentation level.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Jul 12, 2023
@erlend-aasland

erlend-aasland commented Jul 27, 2023

Copy link
Copy Markdown
Contributor Author

Related: I see that _ssl also accidentally got Py_BUILD_CORE_MODULE defined in 46a3190 ;)

How is it an issue to use the internal C API? The internal C API is written for best performances thanks to inlining when you control the argument types.

Well, I'll let you reply yourself (in #88140 (comment)) 😄:

I would prefer to limit the usage of the internal C API in extension modules built as dynamic libraries. See bpo-41111: "[C API] Convert a few stdlib extensions to the limited C API (PEP-384)".

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jul 28, 2023

Copy link
Copy Markdown
Member

I had great hope in being able to convert some stdlib extensions to the limited C API, but then i fall into Argument Clinic and I lost faith. I mean that I found more urgent things to do.

If someone is volunteer to attempt that again, I'm very supportive.

Maybe we might try to define some embargo on abusing private and internal APIs in Python stdlib extensions 😁 It should be the exception, not the default. I'm not sure.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Oct 17, 2023

Copy link
Copy Markdown
Member

Hi, what's the status of this PR?

About converting some stdlib C extensions to the limited C API, you can see: #85283

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland

erlend-aasland commented Oct 22, 2023

Copy link
Copy Markdown
Contributor Author

I don't plan to follow this up right now. If we decide to convert _sqlite3 to use the Limited API in the future, we can revisit this.

vstinner reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland erlend-aasland closed this Oct 22, 2023
@erlend-aasland
erlend-aasland deleted the sqlite-weakref-public-api branch October 22, 2023 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes
@berkerpeksag berkerpeksag Awaiting requested review from berkerpeksag

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting merge skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

The sqlite3 module should not be built as a core module

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@erlend-aasland @vstinner @bedevere-bot
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.