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 — bpo-1635741: port _ctypes extension module to multiphase initialization by kumaraditya303 · Pull Request #30525 · python/cpython

Conversation

@kumaraditya303

@kumaraditya303 kumaraditya303 commented Jan 11, 2022 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

https://bugs.python.org/issue1635741

Sorry, something went wrong.

Uh oh!

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

All reactions
@kumaraditya303
port _ctypes
d72ecb5
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Jan 11, 2022
@bedevere-bot bedevere-bot added the awaiting review label Jan 11, 2022
@blurb-it
📜🤖 Added by blurb_it.
3aaf3ec
@kumaraditya303
kumaraditya303 marked this pull request as ready for review January 11, 2022 04:22
shihai1991
shihai1991 reviewed Jan 11, 2022
View reviewed changes
Comment thread Modules/_ctypes/_ctypes.c
}

static struct PyModuleDef_Slot _ctypes_slots[] = {
{Py_mod_exec, _ctypes_mod_exec},

@shihai1991 shihai1991 Jan 11, 2022

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 am just curious about those codes in _ctypes_mod_exec, do we need judge the attr manually?

_unpickle = PyObject_GetAttrString(mod, "_unpickle");
    if (_unpickle == NULL) {
        return -1;
    }

Sorry, something went wrong.

Uh oh!

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

All reactions
@shihai1991
shihai1991 requested review from corona10 and vstinner January 11, 2022 16:04
vstinner
vstinner requested changes Jan 11, 2022
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.

You should not convert an extension to the multi-phase init API until all static types defined by the extension are defined as heap types.

See _ctypes_add_types(): there are many types defined as static types. Just one example: PyCArg_Type.

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-bot bedevere-bot added awaiting changes and removed awaiting review labels Jan 11, 2022
@bedevere-bot

bedevere-bot commented Jan 11, 2022

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland

erlend-aasland commented Jan 11, 2022

Copy link
Copy Markdown
Contributor

You should not convert an extension to the multi-phase init API until all static types defined by the extension are defined as heap types.

True; but sadly, converting static types to heap types has been put on hold by the SC. The good news is that work is in progress to resolve the "deadlock", so we can continue applying PEP 489 and PEP 630 to the standard library 😃

See SC communications as of February 2021:

"The Steering Council discussed the ongoing work on porting types in the standard library to heap-types and the subinterpreter-related changes. It was decided that through Pablo, the Steering Council will ask the core developers driving those changes to create an informational PEP and not to make any more changes in this area after beta 1, as per our general policy."

All reactions

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland erlend-aasland mentioned this pull request Jan 11, 2022
bpo-1635741: Port _datetime extension module to multiphase initialization (PEP 489) #30522
Closed
@vstinner

vstinner commented Jan 12, 2022

Copy link
Copy Markdown
Member

ask the core developers driving those changes to create an informational PEP

Eric is working on a PEP: python/peps#2212

Not sure if it fulfill SC requirements to convert more static types to heap types.

All reactions

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303

kumaraditya303 commented Jan 12, 2022

Copy link
Copy Markdown
Contributor Author

IIUC converting static types to heap types is a different issue https://bugs.python.org/issue40077 which is not I am tackling in this PR, also itertools module also creates many static types but still uses multiphase initialization

cpython/Modules/itertoolsmodule.c

Line 4907 in be578e0

return PyModuleDef_Init(&itertoolsmodule);
so how is _ctypes different ?

All reactions

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland

erlend-aasland commented Jan 12, 2022

Copy link
Copy Markdown
Contributor

It is subinterpreter related. Also, we first convert global state to module state, then apply multi-phase init, as Victor already pointed out.

Some modules have been converted to multi-phase init prematurely. That does not alter the status quo, or set a precedent.

shihai1991 and CharlieZhao95 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

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

@corona10

corona10 commented Jan 13, 2022

Copy link
Copy Markdown
Member

FYI, Please read https://github.com/vstinner/talks/blob/main/2021-PyconUS/subinterpreters.pdf how we've converted modules :)

erlend-aasland reacted with rocket emoji shihai1991 reacted with eyes emoji
All reactions
  • 🚀 1 reaction
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

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

corona10
corona10 requested changes Jan 13, 2022
View reviewed changes

@corona10 corona10 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.

Same as Victor

Sorry, something went wrong.

Uh oh!

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

All reactions
@kumaraditya303 kumaraditya303 closed this Jan 14, 2022
@erlend-aasland

erlend-aasland commented Jan 28, 2022

Copy link
Copy Markdown
Contributor

FYI: python/steering-council#99

All reactions

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303
kumaraditya303 deleted the ctypes branch January 28, 2022 11:36
@erlend-aasland

erlend-aasland commented Jun 27, 2022

Copy link
Copy Markdown
Contributor

FYI, PEP-687 was just accepted.

All reactions

Sorry, something went wrong.

Uh oh!

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

@kylotan kylotan mannequin mentioned this pull request Sep 19, 2022
Py_Finalize() doesn't clear all Python objects at exit #44470
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@shihai1991 shihai1991 shihai1991 left review comments
@vstinner vstinner vstinner requested changes
@corona10 corona10 corona10 requested changes

Uh oh!

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

Assignees

No one assigned

Labels

awaiting changes

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

7 participants

@kumaraditya303 @bedevere-bot @erlend-aasland @vstinner @corona10 @shihai1991 @the-knights-who-say-ni
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.