Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Nov 24, 2017

Py_GetPath() and Py_Main() now call
_PyMainInterpreterConfig_ReadEnv() to share the same code to get
environment variables.

Changes:

  • Add _PyMainInterpreterConfig_ReadEnv()
  • Add _PyMainInterpreterConfig_Clear()
  • Add _PyMem_RawWcsdup()
  • _PyMainInterpreterConfig: rename pythonhome to home
  • Rename _Py_ReadMainInterpreterConfig() to
    _PyMainInterpreterConfig_Read()
  • Use _Py_INIT_USER_ERR(), instead of _Py_INIT_ERR(), for decoding
    errors: the user is able to fix the issue, it's not a bug in
    Python. Same change was made in _Py_INIT_NO_MEMORY().
  • Remove _Py_GetPythonHomeWithConfig()

https://bugs.python.org/issue32030

Py_GetPath() and Py_Main() now call
_PyMainInterpreterConfig_ReadEnv() to share the same code to get
environment variables.

Changes:

* Add _PyMainInterpreterConfig_ReadEnv()
* Add _PyMainInterpreterConfig_Clear()
* Add _PyMem_RawWcsdup()
* _PyMainInterpreterConfig: rename pythonhome to home
* Rename _Py_ReadMainInterpreterConfig() to
  _PyMainInterpreterConfig_Read()
* Use _Py_INIT_USER_ERR(), instead of _Py_INIT_ERR(), for decoding
  errors: the user is able to fix the issue, it's not a bug in
  Python. Same change was made in _Py_INIT_NO_MEMORY().
* Remove _Py_GetPythonHomeWithConfig()
@vstinner
Copy link
Member Author

@ncoghlan: Previously, I added _Py_GetPythonHomeWithConfig() to be able to iterate slowly on the code. With this change, I was able to remove _Py_GetPythonHomeWithConfig(). Py_GetPath() now also uses internally _PyMainInterpreterConfig to get environment variables. This change is the implementation of what I described you by email.

This PR is only a small enhancement of the current code. You can still expect API changes. I tried to add program_name to _PyMainInterpreterConfig, but then I was stuck since _PyMainInterpreterConfig_ReadEnv() doesn't have access to argc and argv, whereas the code requires argv[0] to initialize program_name.

I have to think about it to see how program_name can be initialized properly.

@vstinner vstinner merged commit 46972b7 into python:master Nov 24, 2017
@vstinner vstinner deleted the mainconfig_read branch November 24, 2017 21:55
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.

3 participants