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

Skip to content

Conversation

@neonene
Copy link
Contributor

@neonene neonene commented Jun 5, 2022

When an embedded Python is initialized multiple times, getpath.py requires home with the same value, for the consistent path configuration.

Roughly, the transition of home (PyInterpreterState.config.home) is as below:

  1. home = config.home(original, local) or _Py_path_config.home(global)
  2. home, paths = getpath(home, PYTHONHOME, *._pth)
  3. _Py_path_config.home = home (the original config.home is left as-is)

1st initialization with PYTHONHOME:

  1. home gets NULL.
  2. getpath receives None as home and returns the value of PYTHONHOME.

2nd:

  1. home starts with PYTHONHOME from _Py_path_config.home.
  2. getpath keeps the existing home unchanged. The returned paths, which are less flexible than 1st, can cause import errors.

In this cycle, the value from _Py_path_config.home at step1 needs to be discarded unless the global value was set by Py_SetPythonHome().

#91985

@neonene
Copy link
Contributor Author

neonene commented Jun 5, 2022

@zooba Could you take a look please?

@neonene neonene marked this pull request as draft June 8, 2022 07:13
@neonene neonene closed this Jun 9, 2022
@neonene neonene deleted the pathconfig branch June 17, 2022 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants