bpo-34170: Rework _PyCoreConfig_Read() to avoid side effect by vstinner · Pull Request #8353 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation8 Commits6 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

vstinner

Rework _PyCoreConfig_Read() function which reads core configuration
to not modify the path configuration.

A new _PyCoreConfig_SetPathConfig() function now recreates the path
configuration from the core configuration. This function is now
called very late in _Py_InitializeCore(), just before calling
initimport().

Changes:

https://bugs.python.org/issue34170

@vstinner

Rework _PyCoreConfig_Read() function which reads core configuration to not modify the path configuration.

A new _PyCoreConfig_SetPathConfig() function now recreates the path configuration from the core configuration. This function is now called very late in _Py_InitializeCore(), just before calling initimport().

Changes:

@vstinner

I don't think that "Add _PyCoreConfig.dll_path" needs a public changelog entry, since the structure is still private.

ncoghlan

Choose a reason for hiding this comment

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

+1 for avoiding side effects when reading the configuration, and the general structure here looks good to me (I didn't look closely at the internals of the relocated functions, though)

vstinner

}
if (config->executable == NULL) {
config->executable = _PyMem_RawWcsdup(path_config.program_full_path);

Choose a reason for hiding this comment

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

Hum, maybe copy_wstr() should be used. I'm not sure if these fields can be NULL or not.

@ncoghlan

While I can't think of a way this could cause an externally visible change in behaviour, if you wanted to backport this to Python 3.7 to keep the code structure consistent, then I think it would need a public change log entry so it appeared in the 3.7.1 notes.

If it remains 3.8 only though, then yeah, I agree it would be covered by the eventual change of making the new initialisation API public.

@vstinner

@vstinner

Py_SetPath() now fails with a fatal python error on memory allocation failure.

@vstinner

@vstinner

@vstinner

@vstinner

I see this change as an enhancement rather than a bugfix. The change is large, I would be risky to backport it. I don't want to backport this change, I wrote it for the master branch only. It's part of a larger effort to fix Py_Main() called after Py_Initialize(): apply the new Py_Main() configuration (not sure if this PR really makes things easier, but I wanted to do this change anyway :-D).

@ZackerySpytz

This commit causes a warning with Clang 5.0.0 (as seen in the TravisCI build):

In file included from Parser/pgenmain.c:20:
./Include/internal/pystate.h:55:3: warning: redefinition of typedef '_PyPathConfig' is a C11 feature [-Wtypedef-redefinition]
} _PyPathConfig;
  ^
./Include/pylifecycle.h:123:30: note: previous definition is here
typedef struct _PyPathConfig _PyPathConfig;
                             ^
1 warning generated.

@vstinner

This commit causes a warning with Clang 5.0.0 (as seen in the TravisCI build):

It should have been fixed now ;-)

fsrrt

Choose a reason for hiding this comment

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