Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review: use wrapper functions instead of low-level accessors
Use _Py_IsCoreInitialized() in preconfig.c and Py_IsInitialized() in
Py_InitializeEx(), removing the unnecessary runtime local variable.

Thanks picnixz!
  • Loading branch information
gpshead committed Mar 22, 2026
commit ba28b37101149f95d2c49b713d7493f2ecb66836
2 changes: 1 addition & 1 deletion Python/preconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ _PyPreConfig_Write(const PyPreConfig *src_config)
return status;
}

if (_PyRuntimeState_GetCoreInitialized(&_PyRuntime)) {
if (_Py_IsCoreInitialized()) {
/* bpo-34008: Calling this functions after Py_Initialize() ignores
the new configuration. */
return _PyStatus_OK();
Expand Down
3 changes: 1 addition & 2 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1505,9 +1505,8 @@ Py_InitializeEx(int install_sigs)
if (_PyStatus_EXCEPTION(status)) {
Py_ExitStatusException(status);
}
_PyRuntimeState *runtime = &_PyRuntime;

if (_PyRuntimeState_GetInitialized(runtime)) {
if (Py_IsInitialized()) {
/* bpo-33932: Calling Py_Initialize() twice does nothing. */
return;
}
Expand Down
Loading