]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-133644: Remove deprecated Python initialization getter functions (#133661)
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>
Fri, 9 May 2025 11:39:23 +0000 (13:39 +0200)
committerGitHub <noreply@github.com>
Fri, 9 May 2025 11:39:23 +0000 (11:39 +0000)
Remove functions:

* Py_GetExecPrefix()
* Py_GetPath()
* Py_GetPrefix()
* Py_GetProgramFullPath()
* Py_GetProgramName()
* Py_GetPythonHome()

18 files changed:
Doc/c-api/init.rst
Doc/c-api/intro.rst
Doc/data/refcounts.dat
Doc/data/stable_abi.dat
Doc/deprecations/c-api-pending-removal-in-3.15.rst
Doc/whatsnew/3.10.rst
Doc/whatsnew/3.13.rst
Doc/whatsnew/3.15.rst
Doc/whatsnew/3.8.rst
Include/pylifecycle.h
Lib/test/test_inspect/test_inspect.py
Lib/test/test_repl.py
Misc/NEWS.d/3.10.0a3.rst
Misc/NEWS.d/3.13.0a1.rst
Misc/NEWS.d/3.9.0a1.rst
Misc/NEWS.d/next/C_API/2025-05-08-13-14-45.gh-issue-133644.J8_KZ2.rst [new file with mode: 0644]
Misc/stable_abi.toml
Python/pathconfig.c

index 52f64a61006b74d91abac87722a1c9e0cab86170..8ea73fa2f630c8e0df675fe3ae1903b9e5fb6bbd 100644 (file)
@@ -77,10 +77,7 @@ The following functions can be safely called before Python is initialized:
 
    Despite their apparent similarity to some of the functions listed above,
    the following functions **should not be called** before the interpreter has
-   been initialized: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPath`,
-   :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`,
-   :c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome`,
-   :c:func:`Py_GetProgramName`, :c:func:`PyEval_InitThreads`, and
+   been initialized: :c:func:`Py_EncodeLocale`, :c:func:`PyEval_InitThreads`, and
    :c:func:`Py_RunMain`.
 
 
@@ -145,9 +142,6 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
    :c:member:`PyConfig.pathconfig_warnings` should be used instead, see
    :ref:`Python Initialization Configuration <init-config>`.
 
-   Suppress error messages when calculating the module search path in
-   :c:func:`Py_GetPath`.
-
    Private flag used by ``_freeze_module`` and ``frozenmain`` programs.
 
    .. deprecated-removed:: 3.12 3.15
@@ -586,7 +580,6 @@ Process-wide parameters
    .. index::
       single: Py_Initialize()
       single: main()
-      single: Py_GetPath()
 
    This API is kept for backward compatibility: setting
    :c:member:`PyConfig.program_name` should be used instead, see :ref:`Python
@@ -596,7 +589,7 @@ Process-wide parameters
    the first time, if it is called at all.  It tells the interpreter the value
    of the ``argv[0]`` argument to the :c:func:`main` function of the program
    (converted to wide characters).
-   This is used by :c:func:`Py_GetPath` and some other functions below to find
+   This is used by some other functions below to find
    the Python run-time libraries relative to the interpreter executable.  The
    default value is ``'python'``.  The argument should point to a
    zero-terminated wide character string in static storage whose contents will not
@@ -609,146 +602,6 @@ Process-wide parameters
    .. deprecated-removed:: 3.11 3.15
 
 
-.. c:function:: wchar_t* Py_GetProgramName()
-
-   Return the program name set with :c:member:`PyConfig.program_name`, or the default.
-   The returned string points into static storage; the caller should not modify its
-   value.
-
-   This function should not be called before :c:func:`Py_Initialize`, otherwise
-   it returns ``NULL``.
-
-   .. versionchanged:: 3.10
-      It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
-
-   .. deprecated-removed:: 3.13 3.15
-      Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
-      (:data:`sys.executable`) instead.
-
-
-.. c:function:: wchar_t* Py_GetPrefix()
-
-   Return the *prefix* for installed platform-independent files. This is derived
-   through a number of complicated rules from the program name set with
-   :c:member:`PyConfig.program_name` and some environment variables; for example, if the
-   program name is ``'/usr/local/bin/python'``, the prefix is ``'/usr/local'``. The
-   returned string points into static storage; the caller should not modify its
-   value.  This corresponds to the :makevar:`prefix` variable in the top-level
-   :file:`Makefile` and the :option:`--prefix` argument to the :program:`configure`
-   script at build time.  The value is available to Python code as ``sys.base_prefix``.
-   It is only useful on Unix.  See also the next function.
-
-   This function should not be called before :c:func:`Py_Initialize`, otherwise
-   it returns ``NULL``.
-
-   .. versionchanged:: 3.10
-      It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
-
-   .. deprecated-removed:: 3.13 3.15
-      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()
-
-   Return the *exec-prefix* for installed platform-*dependent* files.  This is
-   derived through a number of complicated rules from the program name set with
-   :c:member:`PyConfig.program_name` and some environment variables; for example, if the
-   program name is ``'/usr/local/bin/python'``, the exec-prefix is
-   ``'/usr/local'``.  The returned string points into static storage; the caller
-   should not modify its value.  This corresponds to the :makevar:`exec_prefix`
-   variable in the top-level :file:`Makefile` and the ``--exec-prefix``
-   argument to the :program:`configure` script at build  time.  The value is
-   available to Python code as ``sys.base_exec_prefix``.  It is only useful on
-   Unix.
-
-   Background: The exec-prefix differs from the prefix when platform dependent
-   files (such as executables and shared libraries) are installed in a different
-   directory tree.  In a typical installation, platform dependent files may be
-   installed in the :file:`/usr/local/plat` subtree while platform independent may
-   be installed in :file:`/usr/local`.
-
-   Generally speaking, a platform is a combination of hardware and software
-   families, e.g.  Sparc machines running the Solaris 2.x operating system are
-   considered the same platform, but Intel machines running Solaris 2.x are another
-   platform, and Intel machines running Linux are yet another platform.  Different
-   major revisions of the same operating system generally also form different
-   platforms.  Non-Unix operating systems are a different story; the installation
-   strategies on those systems are so different that the prefix and exec-prefix are
-   meaningless, and set to the empty string. Note that compiled Python bytecode
-   files are platform independent (but not independent from the Python version by
-   which they were compiled!).
-
-   System administrators will know how to configure the :program:`mount` or
-   :program:`automount` programs to share :file:`/usr/local` between platforms
-   while having :file:`/usr/local/plat` be a different filesystem for each
-   platform.
-
-   This function should not be called before :c:func:`Py_Initialize`, otherwise
-   it returns ``NULL``.
-
-   .. versionchanged:: 3.10
-      It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
-
-   .. deprecated-removed:: 3.13 3.15
-      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()
-
-   .. index::
-      single: executable (in module sys)
-
-   Return the full program name of the Python executable; this is  computed as a
-   side-effect of deriving the default module search path  from the program name
-   (set by :c:member:`PyConfig.program_name`). The returned string points into
-   static storage; the caller should not modify its value.  The value is available
-   to Python code as ``sys.executable``.
-
-   This function should not be called before :c:func:`Py_Initialize`, otherwise
-   it returns ``NULL``.
-
-   .. versionchanged:: 3.10
-      It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
-
-   .. deprecated-removed:: 3.13 3.15
-      Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
-      (:data:`sys.executable`) instead.
-
-
-.. c:function:: wchar_t* Py_GetPath()
-
-   .. index::
-      triple: module; search; path
-      single: path (in module sys)
-
-   Return the default module search path; this is computed from the program name
-   (set by :c:member:`PyConfig.program_name`) and some environment variables.
-   The returned string consists of a series of directory names separated by a
-   platform dependent delimiter character.  The delimiter character is ``':'``
-   on Unix and macOS, ``';'`` on Windows.  The returned string points into
-   static storage; the caller should not modify its value.  The list
-   :data:`sys.path` is initialized with this value on interpreter startup; it
-   can be (and usually is) modified later to change the search path for loading
-   modules.
-
-   This function should not be called before :c:func:`Py_Initialize`, otherwise
-   it returns ``NULL``.
-
-   .. XXX should give the exact rules
-
-   .. versionchanged:: 3.10
-      It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
-
-   .. deprecated-removed:: 3.13 3.15
-      Use :c:func:`PyConfig_Get("module_search_paths") <PyConfig_Get>`
-      (:data:`sys.path`) instead.
-
 .. c:function:: const char* Py_GetVersion()
 
    Return the version of this Python interpreter.  This is a string that looks
@@ -919,23 +772,6 @@ Process-wide parameters
    .. deprecated-removed:: 3.11 3.15
 
 
-.. c:function:: wchar_t* Py_GetPythonHome()
-
-   Return the default "home", that is, the value set by
-   :c:member:`PyConfig.home`, or the value of the :envvar:`PYTHONHOME`
-   environment variable if it is set.
-
-   This function should not be called before :c:func:`Py_Initialize`, otherwise
-   it returns ``NULL``.
-
-   .. versionchanged:: 3.10
-      It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
-
-   .. deprecated-removed:: 3.13 3.15
-      Use :c:func:`PyConfig_Get("home") <PyConfig_Get>` or the
-      :envvar:`PYTHONHOME` environment variable instead.
-
-
 .. _threads:
 
 Thread State and the Global Interpreter Lock
index 2bad0bab224e516fa8cf0a6df6831c72ba625e00..0c20ad17194eb6248515cbc4269a5431146fd850 100644 (file)
@@ -779,20 +779,11 @@ found along :envvar:`PATH`.)  The user can override this behavior by setting the
 environment variable :envvar:`PYTHONHOME`, or insert additional directories in
 front of the standard path by setting :envvar:`PYTHONPATH`.
 
-.. index::
-   single: Py_GetPath (C function)
-   single: Py_GetPrefix (C function)
-   single: Py_GetExecPrefix (C function)
-   single: Py_GetProgramFullPath (C function)
-
 The embedding application can steer the search by setting
 :c:member:`PyConfig.program_name` *before* calling
 :c:func:`Py_InitializeFromConfig`. Note that
 :envvar:`PYTHONHOME` still overrides this and :envvar:`PYTHONPATH` is still
-inserted in front of the standard path.  An application that requires total
-control has to provide its own implementation of :c:func:`Py_GetPath`,
-:c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`, and
-:c:func:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`).
+inserted in front of the standard path.
 
 .. index:: single: Py_IsInitialized (C function)
 
index 14990bee6e4f230dc8147ab5e57bb84220f5e59b..1eca7bca2e29805330e456b6f75dd650ca5d0301 100644 (file)
@@ -3004,18 +3004,8 @@ Py_GetCompiler:const char*:::
 
 Py_GetCopyright:const char*:::
 
-Py_GetExecPrefix:wchar_t*:::
-
-Py_GetPath:wchar_t*:::
-
 Py_GetPlatform:const char*:::
 
-Py_GetPrefix:wchar_t*:::
-
-Py_GetProgramFullPath:wchar_t*:::
-
-Py_GetProgramName:wchar_t*:::
-
 Py_GetVersion:const char*:::
 
 Py_INCREF:void:::
index a8658d8b80e2945811ba77a21df7876b2b01c0cb..d84addc7ecf851460e87a458b1d824e5b035569b 100644 (file)
@@ -861,13 +861,7 @@ func,Py_GetCompiler,3.2,,
 func,Py_GetConstant,3.13,,
 func,Py_GetConstantBorrowed,3.13,,
 func,Py_GetCopyright,3.2,,
-func,Py_GetExecPrefix,3.2,,
-func,Py_GetPath,3.2,,
 func,Py_GetPlatform,3.2,,
-func,Py_GetPrefix,3.2,,
-func,Py_GetProgramFullPath,3.2,,
-func,Py_GetProgramName,3.2,,
-func,Py_GetPythonHome,3.2,,
 func,Py_GetRecursionLimit,3.2,,
 func,Py_GetVersion,3.2,,
 data,Py_HasFileSystemDefaultEncoding,3.2,,
index a391566c82c2f1e87d58f1bd3c416c239ffb3d55..b87f0a5ecde06f4fcdc127e89ad7237fa82cfd6c 100644 (file)
@@ -22,27 +22,27 @@ Pending removal in Python 3.15
   may return a type other than :class:`bytes`, such as :class:`str`.
 * Python initialization functions, deprecated in Python 3.13:
 
-  * :c:func:`Py_GetPath`:
+  * :c:func:`!Py_GetPath`:
     Use :c:func:`PyConfig_Get("module_search_paths") <PyConfig_Get>`
     (:data:`sys.path`) instead.
-  * :c:func:`Py_GetPrefix`:
+  * :c:func:`!Py_GetPrefix`:
     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`:
+  * :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`:
+  * :c:func:`!Py_GetProgramFullPath`:
     Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
     (:data:`sys.executable`) instead.
-  * :c:func:`Py_GetProgramName`:
+  * :c:func:`!Py_GetProgramName`:
     Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
     (:data:`sys.executable`) instead.
-  * :c:func:`Py_GetPythonHome`:
+  * :c:func:`!Py_GetPythonHome`:
     Use :c:func:`PyConfig_Get("home") <PyConfig_Get>` or the
     :envvar:`PYTHONHOME` environment variable instead.
 
index 3c815721a92f8c8551a755d35d3fc6dd1c46793c..f5e38950756afecbfc2856d64627468df75d9bde 100644 (file)
@@ -2176,9 +2176,9 @@ Porting to Python 3.10
   ``unicodedata.ucnhash_CAPI`` has been moved to the internal C API.
   (Contributed by Victor Stinner in :issue:`42157`.)
 
-* :c:func:`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`,
-  :c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome` and
-  :c:func:`Py_GetProgramName` functions now return ``NULL`` if called before
+* :c:func:`!Py_GetPath`, :c:func:`!Py_GetPrefix`, :c:func:`!Py_GetExecPrefix`,
+  :c:func:`!Py_GetProgramFullPath`, :c:func:`!Py_GetPythonHome` and
+  :c:func:`!Py_GetProgramName` functions now return ``NULL`` if called before
   :c:func:`Py_Initialize` (before Python is initialized). Use the new
   :ref:`init-config` API to get the :ref:`init-path-config`.
   (Contributed by Victor Stinner in :issue:`42260`.)
index ff33224e272c67cbb991e47ce44075f45fcc7014..b3530f75b2fa4078f7dce759c1c5d27e34769f9d 100644 (file)
@@ -2477,17 +2477,17 @@ Deprecated C APIs
 
   * :c:func:`PySys_ResetWarnOptions`:
     Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.
-  * :c:func:`Py_GetExecPrefix`:
+  * :c:func:`!Py_GetExecPrefix`:
     Get :data:`sys.exec_prefix` instead.
-  * :c:func:`Py_GetPath`:
+  * :c:func:`!Py_GetPath`:
     Get :data:`sys.path` instead.
-  * :c:func:`Py_GetPrefix`:
+  * :c:func:`!Py_GetPrefix`:
     Get :data:`sys.prefix` instead.
-  * :c:func:`Py_GetProgramFullPath`:
+  * :c:func:`!Py_GetProgramFullPath`:
     Get :data:`sys.executable` instead.
-  * :c:func:`Py_GetProgramName`:
+  * :c:func:`!Py_GetProgramName`:
     Get :data:`sys.executable` instead.
-  * :c:func:`Py_GetPythonHome`:
+  * :c:func:`!Py_GetPythonHome`:
     Get :c:member:`PyConfig.home`
     or the :envvar:`PYTHONHOME` environment variable instead.
 
index 070d9b38e137d0d872fb4ab58c436a8c4cf3d611..f92e383cce570f1445b6078e98cb1c1807559490 100644 (file)
@@ -169,3 +169,38 @@ Removed C APIs
 
 * :c:func:`!PyImport_ImportModuleNoBlock`: deprecated alias
   of :c:func:`PyImport_ImportModule`.
+
+The following functions are removed in favor of :c:func:`PyConfig_Get`.
+The |pythoncapi_compat_project| can be used to get :c:func:`!PyConfig_Get`
+on Python 3.13 and older.
+
+* Python initialization functions:
+
+  * :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_GetPath`:
+    use :c:func:`PyConfig_Get("module_search_paths") <PyConfig_Get>`
+    (:data:`sys.path`) instead.
+  * :c:func:`!Py_GetPrefix`:
+    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_GetProgramFullPath`:
+    use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
+    (:data:`sys.executable`) instead.
+  * :c:func:`!Py_GetProgramName`:
+    use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
+    (:data:`sys.executable`) instead.
+  * :c:func:`!Py_GetPythonHome`:
+    use :c:func:`PyConfig_Get("home") <PyConfig_Get>` or the
+    :envvar:`PYTHONHOME` environment variable instead.
+
+.. |pythoncapi_compat_project| replace:: |pythoncapi_compat_project_link|_
+.. |pythoncapi_compat_project_link| replace:: pythoncapi-compat project
+.. _pythoncapi_compat_project_link: https://github.com/python/pythoncapi-compat
index 7aca35b2959cd2a2954138b7dec3d8f923864fa1..bc2eb1d0e263f068db28c5af3aac93b283b545ed 100644 (file)
@@ -1629,8 +1629,8 @@ Build and C API Changes
   (Contributed by Pablo Galindo in :issue:`37221`.)
 
 * :c:func:`!Py_SetPath` now sets :data:`sys.executable` to the program full
-  path (:c:func:`Py_GetProgramFullPath`) rather than to the program name
-  (:c:func:`Py_GetProgramName`).
+  path (:c:func:`!Py_GetProgramFullPath`) rather than to the program name
+  (:c:func:`!Py_GetProgramName`).
   (Contributed by Victor Stinner in :issue:`38234`.)
 
 
index de1bcb1d2cb632b026220bc02808352915b61c34..4b3474035cec192566c8e3abf35e5b106a91ac2e 100644 (file)
@@ -35,15 +35,8 @@ PyAPI_FUNC(int) Py_BytesMain(int argc, char **argv);
 
 /* In pathconfig.c */
 Py_DEPRECATED(3.11) PyAPI_FUNC(void) Py_SetProgramName(const wchar_t *);
-Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetProgramName(void);
-
 Py_DEPRECATED(3.11) PyAPI_FUNC(void) Py_SetPythonHome(const wchar_t *);
-Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void);
 
-Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void);
-Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetPrefix(void);
-Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void);
-Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetPath(void);
 #ifdef MS_WINDOWS
 int _Py_CheckPython3(void);
 #endif
index c9b37fcd8f63277540b91ad99e3b561d9240442b..bc1129827079d4bfaba6123293110a65c69a1287 100644 (file)
@@ -6146,12 +6146,14 @@ class TestRepl(unittest.TestCase):
         object.
         """
 
+        # TODO(picnixz): refactor this as it's used by test_repl.py
+
         # To run the REPL without using a terminal, spawn python with the command
         # line option '-i' and the process name set to '<stdin>'.
         # The directory of argv[0] must match the directory of the Python
         # executable for the Popen() call to python to succeed as the directory
-        # path may be used by Py_GetPath() to build the default module search
-        # path.
+        # path may be used by PyConfig_Get("module_search_paths") to build the
+        # default module search path.
         stdin_fname = os.path.join(os.path.dirname(sys.executable), "<stdin>")
         cmd_line = [stdin_fname, '-E', '-i']
         cmd_line.extend(args)
index 228b326699e75fd1fc8a66a128bc2021baf380be..27f16f1ba96566da6f198fce13fa270a552e29c0 100644 (file)
@@ -38,8 +38,8 @@ def spawn_repl(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw):
     # line option '-i' and the process name set to '<stdin>'.
     # The directory of argv[0] must match the directory of the Python
     # executable for the Popen() call to python to succeed as the directory
-    # path may be used by Py_GetPath() to build the default module search
-    # path.
+    # path may be used by PyConfig_Get("module_search_paths") to build the
+    # default module search path.
     stdin_fname = os.path.join(os.path.dirname(sys.executable), "<stdin>")
     cmd_line = [stdin_fname, '-I', '-i']
     cmd_line.extend(args)
index 33c3e14b7a4bcfd09c566337d6e306c455d36d00..3f3fb7ec599e57851f92078c43e43e9617e62b46 100644 (file)
@@ -1395,9 +1395,9 @@ but now can get the condition by calling the new private
 .. nonce: -Br3Co
 .. section: C API
 
-:c:func:`Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`,
-:c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome` and
-:c:func:`Py_GetProgramName` functions now return ``NULL`` if called before
+:c:func:`!Py_GetPath`, :c:func:`!Py_GetPrefix`, :c:func:`!Py_GetExecPrefix`,
+:c:func:`!Py_GetProgramFullPath`, :c:func:`!Py_GetPythonHome` and
+:c:func:`!Py_GetProgramName` functions now return ``NULL`` if called before
 :c:func:`Py_Initialize` (before Python is initialized). Use the new
 :ref:`Python Initialization Configuration API <init-config>` to get the
 :ref:`Python Path Configuration.  <init-path-config>`. Patch by Victor
index 6149b33b07606667fb6fda3cfd26c27f31e2afac..304baf6ac8eea9fe60ac58a44e35665ba9a0520e 100644 (file)
@@ -6593,12 +6593,12 @@ functions, deprecated in Python 3.9. Patch by Victor Stinner.
 Deprecate old Python initialization functions:
 
 * :c:func:`PySys_ResetWarnOptions`
-* :c:func:`Py_GetExecPrefix`
-* :c:func:`Py_GetPath`
-* :c:func:`Py_GetPrefix`
-* :c:func:`Py_GetProgramFullPath`
-* :c:func:`Py_GetProgramName`
-* :c:func:`Py_GetPythonHome`
+* :c:func:`!Py_GetExecPrefix`
+* :c:func:`!Py_GetPath`
+* :c:func:`!Py_GetPrefix`
+* :c:func:`!Py_GetProgramFullPath`
+* :c:func:`!Py_GetProgramName`
+* :c:func:`!Py_GetPythonHome`
 
 Patch by Victor Stinner.
 
index d75132b0aac04063bb214771c9ddf0532cf66959..cc24bae5881df145879b2608846cd934e2493b32 100644 (file)
@@ -5536,8 +5536,8 @@ Tyler Kieft.
 .. section: C API
 
 :c:func:`!Py_SetPath` now sets :data:`sys.executable` to the program full
-path (:c:func:`Py_GetProgramFullPath`) rather than to the program name
-(:c:func:`Py_GetProgramName`).
+path (:c:func:`!Py_GetProgramFullPath`) rather than to the program name
+(:c:func:`!Py_GetProgramName`).
 
 ..
 
diff --git a/Misc/NEWS.d/next/C_API/2025-05-08-13-14-45.gh-issue-133644.J8_KZ2.rst b/Misc/NEWS.d/next/C_API/2025-05-08-13-14-45.gh-issue-133644.J8_KZ2.rst
new file mode 100644 (file)
index 0000000..a9275e8
--- /dev/null
@@ -0,0 +1,2 @@
+Remove deprecated Python initialization getter functions ``Py_Get*``.
+Patch by Bénédikt Tran.
index 886979139ee8a689182d37d4f0554a1e050927b0..76bfaab26ed1b6d52013787b834ee0eeb16f5316 100644 (file)
     added = '3.2'
 [function.Py_GetExecPrefix]
     added = '3.2'
+    abi_only = true
 [function.Py_GetPath]
     added = '3.2'
+    abi_only = true
 [function.Py_GetPlatform]
     added = '3.2'
 [function.Py_GetPrefix]
     added = '3.2'
+    abi_only = true
 [function.Py_GetProgramFullPath]
     added = '3.2'
+    abi_only = true
 [function.Py_GetProgramName]
     added = '3.2'
+    abi_only = true
 [function.Py_GetPythonHome]
     added = '3.2'
+    abi_only = true
 [function.Py_GetRecursionLimit]
     added = '3.2'
 [function.Py_GetVersion]
index 92360c1bb0242041cc5992ce12b6dbf4053c2f75..d034562c43f23c39c8ea70c0464ab76b4f7ff75b 100644 (file)
@@ -272,7 +272,8 @@ Py_SetProgramName(const wchar_t *program_name)
 }
 
 
-wchar_t *
+/* removed in 3.15, but kept for stable ABI compatibility */
+PyAPI_FUNC(wchar_t *)
 Py_GetPath(void)
 {
     /* If the user has provided a path, return that */
@@ -284,7 +285,7 @@ Py_GetPath(void)
 }
 
 
-wchar_t *
+PyAPI_FUNC(wchar_t *)
 _Py_GetStdlibDir(void)
 {
     wchar_t *stdlib_dir = _Py_path_config.stdlib_dir;
@@ -295,35 +296,40 @@ _Py_GetStdlibDir(void)
 }
 
 
-wchar_t *
+/* removed in 3.15, but kept for stable ABI compatibility */
+PyAPI_FUNC(wchar_t *)
 Py_GetPrefix(void)
 {
     return _Py_path_config.prefix;
 }
 
 
-wchar_t *
+/* removed in 3.15, but kept for stable ABI compatibility */
+PyAPI_FUNC(wchar_t *)
 Py_GetExecPrefix(void)
 {
     return _Py_path_config.exec_prefix;
 }
 
 
-wchar_t *
+/* removed in 3.15, but kept for stable ABI compatibility */
+PyAPI_FUNC(wchar_t *)
 Py_GetProgramFullPath(void)
 {
     return _Py_path_config.program_full_path;
 }
 
 
-wchar_t*
+/* removed in 3.15, but kept for stable ABI compatibility */
+PyAPI_FUNC(wchar_t *)
 Py_GetPythonHome(void)
 {
     return _Py_path_config.home;
 }
 
 
-wchar_t *
+/* removed in 3.15, but kept for stable ABI compatibility */
+PyAPI_FUNC(wchar_t *)
 Py_GetProgramName(void)
 {
     return _Py_path_config.program_name;