Skip to content

gh-153300: Set global configuration variables in PyConfig_Set()#153301

Merged
vstinner merged 4 commits into
python:mainfrom
vstinner:config_set_global
Jul 8, 2026
Merged

gh-153300: Set global configuration variables in PyConfig_Set()#153301
vstinner merged 4 commits into
python:mainfrom
vstinner:config_set_global

Conversation

@vstinner

@vstinner vstinner commented Jul 7, 2026

Copy link
Copy Markdown
Member

PyConfig_Set() now also set global configuration variables. For example, PyConfig_Set("inspect", value) now also sets Py_InspectFlag.

Use PyConfig_Set() in main.c to set the inspect flag. Python code can now see the updated sys.flags.inspect value.

PyConfig_Set() now also set global configuration variables. For
example, PyConfig_Set("inspect", value) now also sets Py_InspectFlag.

Use PyConfig_Set() in main.c to set the inspect flag. Python code can
now see the updated sys.flags.inspect value.
@vstinner vstinner added the needs backport to 3.14 bugs and security fixes label Jul 7, 2026
@vstinner vstinner added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 7, 2026
vstinner added 2 commits July 8, 2026 14:05
legacy_windows_stdio is read-only.
@vstinner

vstinner commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Example (new behavior):

$ ./python -i -c 'import sys; print(sys.flags.inspect)'
1
>>> import sys; sys.flags.inspect
0

Old behavior:

$ python3.15 -i -c 'import sys; print(sys.flags.inspect)'
1
>>> import sys; sys.flags.inspect
1

@vstinner vstinner enabled auto-merge (squash) July 8, 2026 16:27
@vstinner vstinner merged commit 9fb713f into python:main Jul 8, 2026
54 checks passed
@vstinner vstinner deleted the config_set_global branch July 8, 2026 16:56
@miss-islington-app

Copy link
Copy Markdown

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @vstinner, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 9fb713f1b8b774c789db007e3824c766a626ccff 3.14

@bedevere-app

bedevere-app Bot commented Jul 8, 2026

Copy link
Copy Markdown

GH-153356 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 8, 2026
@bedevere-app

bedevere-app Bot commented Jul 8, 2026

Copy link
Copy Markdown

GH-153359 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jul 8, 2026
vstinner added a commit that referenced this pull request Jul 8, 2026
#153301) (#153359)

gh-153300: Set global configuration variables in PyConfig_Set() (#153301)

PyConfig_Set() now also set global configuration variables. For
example, PyConfig_Set("inspect", value) now also sets Py_InspectFlag.

Use PyConfig_Set() in main.c to set the inspect flag. Python code can
now see the updated sys.flags.inspect value.

(cherry picked from commit 9fb713f)
vstinner added a commit that referenced this pull request Jul 8, 2026
GH-153301) (#153356)

gh-153300: Set global configuration variables in PyConfig_Set() (GH-153301)

PyConfig_Set() now also set global configuration variables. For
example, PyConfig_Set("inspect", value) now also sets Py_InspectFlag.

Use PyConfig_Set() in main.c to set the inspect flag. Python code can
now see the updated sys.flags.inspect value.
(cherry picked from commit 9fb713f)

Co-authored-by: Victor Stinner <vstinner@python.org>
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.

1 participant