Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove Py_GetProgramFullPath
  • Loading branch information
picnixz committed May 8, 2025
commit 2a578404624465ed4b17e5b8ca3c62afeabe79d6
24 changes: 1 addition & 23 deletions Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +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_GetProgramFullPath`, :c:func:`Py_GetPythonHome`, :c:func:`PyEval_InitThreads`, and
been initialized: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPythonHome`, :c:func:`PyEval_InitThreads`, and
:c:func:`Py_RunMain`.


Expand Down Expand Up @@ -602,28 +602,6 @@ Process-wide parameters
.. deprecated-removed:: 3.11 3.15


.. 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:: const char* Py_GetVersion()

Return the version of this Python interpreter. This is a string that looks
Expand Down
7 changes: 1 addition & 6 deletions Doc/c-api/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -779,16 +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_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_GetProgramFullPath`
(defined in :file:`Modules/getpath.c`).
inserted in front of the standard path.

.. index:: single: Py_IsInitialized (C function)

Expand Down
2 changes: 0 additions & 2 deletions Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -3009,8 +3009,6 @@ Py_GetCopyright:const char*:::

Py_GetPlatform:const char*:::

Py_GetProgramFullPath:wchar_t*:::

Py_GetVersion:const char*:::

Py_INCREF:void:::
Expand Down
1 change: 0 additions & 1 deletion Doc/data/stable_abi.dat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Doc/deprecations/c-api-pending-removal-in-3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ 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_GetProgramFullPath`:
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.
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,7 @@ Porting to Python 3.10
(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_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`.
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2483,7 +2483,7 @@ Deprecated C APIs
Get :data:`sys.path` instead.
* :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`:
Get :data:`sys.executable` instead.
Expand Down
3 changes: 3 additions & 0 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ Removed C APIs
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.
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,7 @@ 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
path (:c:func:`!Py_GetProgramFullPath`) rather than to the program name
(:c:func:`!Py_GetProgramName`).
(Contributed by Victor Stinner in :issue:`38234`.)

Expand Down
1 change: 0 additions & 1 deletion Include/pylifecycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Py_DEPRECATED(3.11) PyAPI_FUNC(void) Py_SetProgramName(const wchar_t *);
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);
#ifdef MS_WINDOWS
int _Py_CheckPython3(void);
#endif
Expand Down
3 changes: 0 additions & 3 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,6 @@ def test_getpath_abspath_win32(self):
def test_global_pathconfig(self):
# Test C API functions getting the path configuration:
#
# - Py_GetProgramFullPath()
# - Py_GetPythonHome()
#
# The global path configuration (_Py_path_config) must be a copy
Expand All @@ -1721,12 +1720,10 @@ def get_func(name):
func.restype = ctypes.c_wchar_p
return func

Py_GetProgramFullPath = get_func('Py_GetProgramFullPath')
Py_GetPythonHome = get_func('Py_GetPythonHome')

config = _testinternalcapi.get_configs()['config']

self.assertEqual(Py_GetProgramFullPath(), config['executable'])
self.assertEqual(Py_GetPythonHome(), config['home'])

def test_init_warnoptions(self):
Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.10.0a3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,7 @@ but now can get the condition by calling the new private
.. 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_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
Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.13.0a1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6596,7 +6596,7 @@ Deprecate old Python initialization functions:
* :c:func:`!Py_GetExecPrefix`
* :c:func:`!Py_GetPath`
* :c:func:`!Py_GetPrefix`
* :c:func:`Py_GetProgramFullPath`
* :c:func:`!Py_GetProgramFullPath`
* :c:func:`!Py_GetProgramName`
* :c:func:`Py_GetPythonHome`

Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.9.0a1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5536,7 +5536,7 @@ 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
path (:c:func:`!Py_GetProgramFullPath`) rather than to the program name
(:c:func:`!Py_GetProgramName`).

..
Expand Down
2 changes: 0 additions & 2 deletions Misc/stable_abi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1632,8 +1632,6 @@
added = '3.2'
[function.Py_GetPlatform]
added = '3.2'
[function.Py_GetProgramFullPath]
added = '3.2'
[function.Py_GetPythonHome]
added = '3.2'
[function.Py_GetRecursionLimit]
Comment thread
picnixz marked this conversation as resolved.
Expand Down
1 change: 0 additions & 1 deletion PC/python3dll.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions Python/pathconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,6 @@ _Py_GetStdlibDir(void)
}


wchar_t *
Py_GetProgramFullPath(void)
{
return _Py_path_config.program_full_path;
}


wchar_t*
Py_GetPythonHome(void)
{
Expand Down