Skip to content

bpo-38234: Fix _PyConfig_InitPathConfig()#16335

Merged
vstinner merged 3 commits intopython:masterfrom
vstinner:pathconfig_fix2
Sep 23, 2019
Merged

bpo-38234: Fix _PyConfig_InitPathConfig()#16335
vstinner merged 3 commits intopython:masterfrom
vstinner:pathconfig_fix2

Conversation

@vstinner
Copy link
Copy Markdown
Member

@vstinner vstinner commented Sep 23, 2019

  • _PyConfig_InitPathConfig() now starts by copying the global path
    configuration, and then override values set in PyConfig.
  • _PyPathConfig_Calculate() implementations no longer override
    _PyPathConfig fields which are already computed. For example,
    if _PyPathConfig.prefix is not NULL, leave it unchanged.
  • If Py_SetPath() has been called, _PyConfig_InitPathConfig() doesn't
    _PyPathConfig_Calculate() anymore.
  • _PyPathConfig_Calculate() now only uses PyConfig to initialize
    PyCalculatePath structure.
  • pathconfig_calculate(): remove useless temporary
    "_PyPathConfig new_config" variable.
  • calculate_module_search_path(): remove hack to workaround memory
    allocation failure, call Py_FatalError() instead.
  • Fix get_program_full_path(): handle memory allocation failure.

https://bugs.python.org/issue38234

* _PyConfig_InitPathConfig() now starts by copying the global path
  configuration, and then override values set in PyConfig.
* _PyPathConfig_Calculate() implementations no longer override
  _PyPathConfig fields which are already computed. For example,
  if _PyPathConfig.prefix is not NULL, leave it unchanged.
* If Py_SetPath() has been called, _PyConfig_InitPathConfig() doesn't
  _PyPathConfig_Calculate() anymore.
* _PyPathConfig_Calculate() now only uses PyConfig to initialize
  PyCalculatePath structure.
* pathconfig_calculate(): remove useless temporary
  "_PyPathConfig new_config" variable.
* calculate_module_search_path(): remove hack to workaround memory
  allocation failure, call Py_FatalError() instead.
* Fix get_program_full_path(): handle memory allocation failure.
Comment thread Python/pathconfig.c Outdated
@vstinner
Copy link
Copy Markdown
Member Author

If Py_SetPath() has been called, _PyConfig_InitPathConfig() doesn't _PyPathConfig_Calculate() anymore.

_PyConfig_InitPathConfig() doesn't call _PyPathConfig_Calculate() anymore.

@vstinner vstinner merged commit 9c42f8c into python:master Sep 23, 2019
@vstinner vstinner deleted the pathconfig_fix2 branch September 23, 2019 16:47
@miss-islington
Copy link
Copy Markdown
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington
Copy link
Copy Markdown
Contributor

Sorry @vstinner, I had trouble checking out the 3.8 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 9c42f8cda552694f3b47d6388d4ae84d61731872 3.8

@bedevere-bot
Copy link
Copy Markdown

GH-16336 is a backport of this pull request to the 3.8 branch.

vstinner added a commit that referenced this pull request Sep 23, 2019
* _PyConfig_InitPathConfig() now starts by copying the global path
  configuration, and then override values set in PyConfig.
* _PyPathConfig_Calculate() implementations no longer override
  _PyPathConfig fields which are already computed. For example,
  if _PyPathConfig.prefix is not NULL, leave it unchanged.
* If Py_SetPath() has been called, _PyConfig_InitPathConfig() doesn't
  call _PyPathConfig_Calculate() anymore.
* _PyPathConfig_Calculate() no longer uses PyConfig,
  except to initialize PyCalculatePath structure.
* pathconfig_calculate(): remove useless temporary
  "_PyPathConfig new_config" variable.
* calculate_module_search_path(): remove hack to workaround memory
  allocation failure, call Py_FatalError() instead.
* Fix get_program_full_path(): handle memory allocation failure.

(cherry picked from commit 9c42f8c)
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.

5 participants