https://github.com/python/cpython/commit/632ca568219f86679661bc288f46fa5838102ede
commit: 632ca568219f86679661bc288f46fa5838102ede
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2025-02-03T12:36:41+01:00
summary:
gh-129342: Explain how to replace Py_GetProgramName() in C (#129361)
files:
M Doc/c-api/init.rst
M Doc/deprecations/c-api-pending-removal-in-3.15.rst
diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst
index dc44f3eaf87765..8e3be97dfeefd1 100644
--- a/Doc/c-api/init.rst
+++ b/Doc/c-api/init.rst
@@ -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:
diff --git a/Doc/deprecations/c-api-pending-removal-in-3.15.rst
b/Doc/deprecations/c-api-pending-removal-in-3.15.rst
index ac31b3cc8cd451..666a1622dd0b29 100644
--- a/Doc/deprecations/c-api-pending-removal-in-3.15.rst
+++ b/Doc/deprecations/c-api-pending-removal-in-3.15.rst
@@ -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.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]