Skip to content

bpo-22257: Private C-API for core runtime initialization (PEP 432). #1772

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

Merged

Conversation

ericsnowcurrently
Copy link
Member

(Patch by Nick Coghlan / @ncoghlan)

Mostly this adds _PyCoreConfig/_Py_InitializeCore() and reorganizes interpreter initialization code around them. The changes align with PEP 432. The new functions are introduced here as "private" C-API while the PEP is discussed. Regardless of the status of the PEP, the changes here are an improvement to interpreter startup. As such we are making the changes now, but keeping the C-API private.

@mention-bot
Copy link

@ericsnowcurrently, thanks for your PR! By analyzing the history of the files in this pull request, we identified @zooba, @ncoghlan and @birkenfeld to be potential reviewers.

@ericsnowcurrently
Copy link
Member Author

@zooba

Copy link
Member

@zooba zooba left a comment

Choose a reason for hiding this comment

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

LGTM with the fixes mentioned

*/

/* #define _INIT_DEBUG_PRINT(msg) printf(msg) */
#define _INIT_DEBUG_PRINT(msg)
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to stay? Should we have a build option to reenable it? Or a comment explaining it?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for dropping it (this is brute force debugging hackery left over from when the modified interpreter was crashing on startup)

that we can call Py_Initialize / Py_FinalizeEx multiple times. */
_PyEval_FiniThreads();

Copy link
Member

Choose a reason for hiding this comment

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

What's with the change in this section?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure. Given the comment I expect it wasn't intentional.

Copy link
Contributor

Choose a reason for hiding this comment

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

Almost certainly the result of a merge glitch somewhere along the line when I was still maintaining the patch out of tree.

if (!tstate)
Py_FatalError("Py_Initialize: failed to read thread state");
interp = tstate->interp;
if (!tstate)
Copy link
Member

Choose a reason for hiding this comment

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

if (!interp)

core_config.ignore_environment = Py_IgnoreEnvironmentFlag;
core_config._disable_importlib = !install_importlib;
_Py_InitializeCore(&core_config);
_Py_InitializeMainInterpreter(install_sigs);
Copy link
Member

Choose a reason for hiding this comment

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

This is where we'd trigger the extra initialization step, right?

Also, why not put install_sigs into core_config?

Copy link
Member Author

Choose a reason for hiding this comment

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

Both of those are sorted out in the next PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

But for anyone just reading these comments: "install_sigs" becomes the first field in the new config struct for the main interpreter, rather than being needed to get the core runtime going :)

@ericsnowcurrently ericsnowcurrently merged commit 1abcf67 into python:master May 24, 2017
@ericsnowcurrently ericsnowcurrently deleted the pep-432-core-config branch May 24, 2017 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants