mirror of
https://github.com/python/cpython.git
synced 2025-12-09 10:37:17 +00:00
gh-129342: Explain how to replace Py_GetProgramName() in C (#129361)
This commit is contained in:
parent
a33dcb9e43
commit
632ca56821
2 changed files with 41 additions and 23 deletions
|
|
@ -622,7 +622,8 @@ Process-wide parameters
|
|||
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
|
||||
|
||||
.. deprecated-removed:: 3.13 3.15
|
||||
Get :data:`sys.executable` instead.
|
||||
Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
|
||||
(:data:`sys.executable`) instead.
|
||||
|
||||
|
||||
.. c:function:: wchar_t* Py_GetPrefix()
|
||||
|
|
@ -644,8 +645,10 @@ Process-wide parameters
|
|||
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
|
||||
|
||||
.. deprecated-removed:: 3.13 3.15
|
||||
Get :data:`sys.base_prefix` instead, or :data:`sys.prefix` if
|
||||
:ref:`virtual environments <venv-def>` need to be handled.
|
||||
Use :c:func:`PyConfig_Get("base_prefix") <PyConfig_Get>`
|
||||
(:data:`sys.base_prefix`) instead. Use :c:func:`PyConfig_Get("prefix")
|
||||
<PyConfig_Get>` (:data:`sys.prefix`) if :ref:`virtual environments
|
||||
<venv-def>` need to be handled.
|
||||
|
||||
|
||||
.. c:function:: wchar_t* Py_GetExecPrefix()
|
||||
|
|
@ -690,9 +693,11 @@ Process-wide parameters
|
|||
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
|
||||
|
||||
.. deprecated-removed:: 3.13 3.15
|
||||
Get :data:`sys.base_exec_prefix` instead, or :data:`sys.exec_prefix` if
|
||||
:ref:`virtual environments <venv-def>` need to be handled.
|
||||
|
||||
Use :c:func:`PyConfig_Get("base_exec_prefix") <PyConfig_Get>`
|
||||
(:data:`sys.base_exec_prefix`) instead. Use
|
||||
:c:func:`PyConfig_Get("exec_prefix") <PyConfig_Get>`
|
||||
(:data:`sys.exec_prefix`) if :ref:`virtual environments <venv-def>` need
|
||||
to be handled.
|
||||
|
||||
.. c:function:: wchar_t* Py_GetProgramFullPath()
|
||||
|
||||
|
|
@ -712,7 +717,8 @@ Process-wide parameters
|
|||
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
|
||||
|
||||
.. deprecated-removed:: 3.13 3.15
|
||||
Get :data:`sys.executable` instead.
|
||||
Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
|
||||
(:data:`sys.executable`) instead.
|
||||
|
||||
|
||||
.. c:function:: wchar_t* Py_GetPath()
|
||||
|
|
@ -740,8 +746,8 @@ Process-wide parameters
|
|||
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
|
||||
|
||||
.. deprecated-removed:: 3.13 3.15
|
||||
Get :data:`sys.path` instead.
|
||||
|
||||
Use :c:func:`PyConfig_Get("module_search_paths") <PyConfig_Get>`
|
||||
(:data:`sys.path`) instead.
|
||||
|
||||
.. c:function:: const char* Py_GetVersion()
|
||||
|
||||
|
|
@ -926,8 +932,8 @@ Process-wide parameters
|
|||
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
|
||||
|
||||
.. deprecated-removed:: 3.13 3.15
|
||||
Get :c:member:`PyConfig.home` or :envvar:`PYTHONHOME` environment
|
||||
variable instead.
|
||||
Use :c:func:`PyConfig_Get("home") <PyConfig_Get>` or the
|
||||
:envvar:`PYTHONHOME` environment variable instead.
|
||||
|
||||
|
||||
.. _threads:
|
||||
|
|
|
|||
|
|
@ -10,25 +10,35 @@ Pending removal in Python 3.15
|
|||
:c:func:`PyWeakref_GetRef` on Python 3.12 and older.
|
||||
* :c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro:
|
||||
Use :c:type:`wchar_t` instead.
|
||||
* Python initialization functions:
|
||||
* Python initialization functions, deprecated in Python 3.13:
|
||||
|
||||
* :c:func:`PySys_ResetWarnOptions`:
|
||||
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.
|
||||
* :c:func:`Py_GetExecPrefix`:
|
||||
Get :data:`sys.base_exec_prefix` and :data:`sys.exec_prefix` instead.
|
||||
* :c:func:`Py_GetPath`:
|
||||
Get :data:`sys.path` instead.
|
||||
Use :c:func:`PyConfig_Get("module_search_paths") <PyConfig_Get>`
|
||||
(:data:`sys.path`) instead.
|
||||
* :c:func:`Py_GetPrefix`:
|
||||
Get :data:`sys.base_prefix` and :data:`sys.prefix` instead.
|
||||
Use :c:func:`PyConfig_Get("base_prefix") <PyConfig_Get>`
|
||||
(:data:`sys.base_prefix`) instead. Use :c:func:`PyConfig_Get("prefix")
|
||||
<PyConfig_Get>` (:data:`sys.prefix`) if :ref:`virtual environments
|
||||
<venv-def>` need to be handled.
|
||||
* :c:func:`Py_GetExecPrefix`:
|
||||
Use :c:func:`PyConfig_Get("base_exec_prefix") <PyConfig_Get>`
|
||||
(:data:`sys.base_exec_prefix`) instead. Use
|
||||
:c:func:`PyConfig_Get("exec_prefix") <PyConfig_Get>`
|
||||
(:data:`sys.exec_prefix`) if :ref:`virtual environments <venv-def>` need to
|
||||
be handled.
|
||||
* :c:func:`Py_GetProgramFullPath`:
|
||||
Get :data:`sys.executable` instead.
|
||||
Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
|
||||
(:data:`sys.executable`) instead.
|
||||
* :c:func:`Py_GetProgramName`:
|
||||
Get :data:`sys.executable` instead.
|
||||
Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
|
||||
(:data:`sys.executable`) instead.
|
||||
* :c:func:`Py_GetPythonHome`:
|
||||
Get :c:func:`PyConfig_Get("home") <PyConfig_Get>`
|
||||
or the :envvar:`PYTHONHOME` environment variable instead.
|
||||
Use :c:func:`PyConfig_Get("home") <PyConfig_Get>` or the
|
||||
:envvar:`PYTHONHOME` environment variable instead.
|
||||
|
||||
See also the :c:func:`PyConfig_Get` function.
|
||||
The `pythoncapi-compat project
|
||||
<https://github.com/python/pythoncapi-compat/>`__ can be used to get
|
||||
:c:func:`PyConfig_Get` on Python 3.13 and older.
|
||||
|
||||
* Functions to configure Python's initialization, deprecated in Python 3.11:
|
||||
|
||||
|
|
@ -40,6 +50,8 @@ Pending removal in Python 3.15
|
|||
Set :c:member:`PyConfig.program_name` instead.
|
||||
* :c:func:`!Py_SetPythonHome()`:
|
||||
Set :c:member:`PyConfig.home` instead.
|
||||
* :c:func:`PySys_ResetWarnOptions`:
|
||||
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.
|
||||
|
||||
The :c:func:`Py_InitializeFromConfig` API should be used with
|
||||
:c:type:`PyConfig` instead.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue