Skip to content

bpo-46964: Move PyInterpreterState.config to _PyRuntimeState.config#31771

Draft
ericsnowcurrently wants to merge 12 commits intopython:mainfrom
ericsnowcurrently:runtime-config
Draft

bpo-46964: Move PyInterpreterState.config to _PyRuntimeState.config#31771
ericsnowcurrently wants to merge 12 commits intopython:mainfrom
ericsnowcurrently:runtime-config

Conversation

@ericsnowcurrently
Copy link
Copy Markdown
Member

@ericsnowcurrently ericsnowcurrently commented Mar 8, 2022

As part of this, we also move PyConfig._isolated_interpreter to a new _PyInterpreterConfig struct and split it up into more granular settings. We also change some of the private API names to explicitly indicate they relate to global config.

https://bugs.python.org/issue46964

Comment thread Python/initconfig.c Outdated
Comment thread Python/initconfig.c Outdated
/* Allow the creation of threads. */
unsigned int allow_threading:1;
/* Padding to ensure byte alignment. */
unsigned int :5;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

structs must be at least byte aligned, so this isn't strictly necessary.

Comment thread Modules/main.c
PyInterpreterState *interp = _PyInterpreterState_GET();
/* pymain_run_stdin() modify the config */
PyConfig *config = (PyConfig*)_PyInterpreterState_GetConfig(interp);
PyConfig *config = (PyConfig*)_PyInterpreterState_GetGlobalConfig(interp);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why the cast?

Comment thread Objects/unicodeobject.c
{
/* Update the stdio encoding to the normalized Python codec name. */
PyConfig *config = (PyConfig*)_PyInterpreterState_GetConfig(interp);
PyConfig *config = (PyConfig*)_PyInterpreterState_GetGlobalConfig(interp);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove the cast?

Comment thread Objects/unicodeobject.c
For example, replace "ANSI_X3.4-1968" (locale encoding) with "ascii"
(Python codec name). */
PyConfig *config = (PyConfig*)_PyInterpreterState_GetConfig(interp);
PyConfig *config = (PyConfig*)_PyInterpreterState_GetGlobalConfig(interp);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto

Comment thread Objects/unicodeobject.c
{
PyInterpreterState *interp = _PyInterpreterState_GET();
PyConfig *config = (PyConfig *)_PyInterpreterState_GetConfig(interp);
PyConfig *config = (PyConfig *)_PyInterpreterState_GetGlobalConfig(interp);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto

Comment thread Python/initconfig.c
void
_PyInterpreterConfig_Clear(_PyInterpreterConfig *config)
{
*config = (_PyInterpreterConfig){};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

needs struct?

Comment thread Python/pylifecycle.c
}

status = _PyConfig_Copy(&tstate->interp->config, &config);
status = _PyConfig_Copy(&tstate->interp->runtime->config, &config);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems a very convoluted way to get a static object

@kumaraditya303 kumaraditya303 removed their request for review November 30, 2022 16:22
@encukou
Copy link
Copy Markdown
Member

encukou commented Mar 19, 2024

_PyInterpreterConfig has been added in #98609.
@ericsnowcurrently, do you have any more plans with this PR?

@ericsnowcurrently
Copy link
Copy Markdown
Member Author

Yeah, there are a few things that I need to follow up on here.

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants