Skip to content

Commit 00ed990

Browse files
committed
remove Py_GetPrefix
1 parent 5304e49 commit 00ed990

File tree

16 files changed

+13
-56
lines changed

16 files changed

+13
-56
lines changed

Doc/c-api/init.rst

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ The following functions can be safely called before Python is initialized:
7777

7878
Despite their apparent similarity to some of the functions listed above,
7979
the following functions **should not be called** before the interpreter has
80-
been initialized: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPrefix`, :c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome`, :c:func:`PyEval_InitThreads`, and
80+
been initialized: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome`, :c:func:`PyEval_InitThreads`, and
8181
:c:func:`Py_RunMain`.
8282

8383

@@ -602,31 +602,6 @@ Process-wide parameters
602602
.. deprecated-removed:: 3.11 3.15
603603
604604
605-
.. c:function:: wchar_t* Py_GetPrefix()
606-
607-
Return the *prefix* for installed platform-independent files. This is derived
608-
through a number of complicated rules from the program name set with
609-
:c:member:`PyConfig.program_name` and some environment variables; for example, if the
610-
program name is ``'/usr/local/bin/python'``, the prefix is ``'/usr/local'``. The
611-
returned string points into static storage; the caller should not modify its
612-
value. This corresponds to the :makevar:`prefix` variable in the top-level
613-
:file:`Makefile` and the :option:`--prefix` argument to the :program:`configure`
614-
script at build time. The value is available to Python code as ``sys.base_prefix``.
615-
It is only useful on Unix. See also the next function.
616-
617-
This function should not be called before :c:func:`Py_Initialize`, otherwise
618-
it returns ``NULL``.
619-
620-
.. versionchanged:: 3.10
621-
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
622-
623-
.. deprecated-removed:: 3.13 3.15
624-
Use :c:func:`PyConfig_Get("base_prefix") <PyConfig_Get>`
625-
(:data:`sys.base_prefix`) instead. Use :c:func:`PyConfig_Get("prefix")
626-
<PyConfig_Get>` (:data:`sys.prefix`) if :ref:`virtual environments
627-
<venv-def>` need to be handled.
628-
629-
630605
.. c:function:: wchar_t* Py_GetProgramFullPath()
631606
632607
.. index::

Doc/c-api/intro.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,16 +780,15 @@ environment variable :envvar:`PYTHONHOME`, or insert additional directories in
780780
front of the standard path by setting :envvar:`PYTHONPATH`.
781781

782782
.. index::
783-
single: Py_GetPrefix (C function)
784783
single: Py_GetProgramFullPath (C function)
785784

786785
The embedding application can steer the search by setting
787786
:c:member:`PyConfig.program_name` *before* calling
788787
:c:func:`Py_InitializeFromConfig`. Note that
789788
:envvar:`PYTHONHOME` still overrides this and :envvar:`PYTHONPATH` is still
790789
inserted in front of the standard path. An application that requires total
791-
control has to provide its own implementation of :c:func:`Py_GetPrefix`, and
792-
:c:func:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`).
790+
control has to provide its own implementation of :c:func:`Py_GetProgramFullPath`
791+
(defined in :file:`Modules/getpath.c`).
793792

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

Doc/data/refcounts.dat

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,8 +3009,6 @@ Py_GetCopyright:const char*:::
30093009

30103010
Py_GetPlatform:const char*:::
30113011

3012-
Py_GetPrefix:wchar_t*:::
3013-
30143012
Py_GetProgramFullPath:wchar_t*:::
30153013

30163014
Py_GetVersion:const char*:::

Doc/data/stable_abi.dat

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/deprecations/c-api-pending-removal-in-3.15.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ Pending removal in Python 3.15
2222
may return a type other than :class:`bytes`, such as :class:`str`.
2323
* Python initialization functions, deprecated in Python 3.13:
2424

25-
* :c:func:`Py_GetPrefix`:
26-
Use :c:func:`PyConfig_Get("base_prefix") <PyConfig_Get>`
27-
(:data:`sys.base_prefix`) instead. Use :c:func:`PyConfig_Get("prefix")
28-
<PyConfig_Get>` (:data:`sys.prefix`) if :ref:`virtual environments
29-
<venv-def>` need to be handled.
3025
* :c:func:`Py_GetProgramFullPath`:
3126
Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
3227
(:data:`sys.executable`) instead.

Doc/whatsnew/3.10.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2176,7 +2176,7 @@ Porting to Python 3.10
21762176
``unicodedata.ucnhash_CAPI`` has been moved to the internal C API.
21772177
(Contributed by Victor Stinner in :issue:`42157`.)
21782178
2179-
* :c:func:`!Py_GetPath`, :c:func:`Py_GetPrefix`, :c:func:`!Py_GetExecPrefix`,
2179+
* :c:func:`!Py_GetPath`, :c:func:`!Py_GetPrefix`, :c:func:`!Py_GetExecPrefix`,
21802180
:c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome` and
21812181
:c:func:`!Py_GetProgramName` functions now return ``NULL`` if called before
21822182
:c:func:`Py_Initialize` (before Python is initialized). Use the new

Doc/whatsnew/3.13.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2481,7 +2481,7 @@ Deprecated C APIs
24812481
Get :data:`sys.exec_prefix` instead.
24822482
* :c:func:`!Py_GetPath`:
24832483
Get :data:`sys.path` instead.
2484-
* :c:func:`Py_GetPrefix`:
2484+
* :c:func:`!Py_GetPrefix`:
24852485
Get :data:`sys.prefix` instead.
24862486
* :c:func:`Py_GetProgramFullPath`:
24872487
Get :data:`sys.executable` instead.

Doc/whatsnew/3.15.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ Removed C APIs
164164
* :c:func:`!Py_GetPath`:
165165
use :c:func:`PyConfig_Get("module_search_paths") <PyConfig_Get>`
166166
(:data:`sys.path`) instead.
167+
* :c:func:`!Py_GetPrefix`:
168+
use :c:func:`PyConfig_Get("base_prefix") <PyConfig_Get>`
169+
(:data:`sys.base_prefix`) instead.
170+
Use :c:func:`PyConfig_Get("prefix") <PyConfig_Get>`
171+
(:data:`sys.prefix`) if :ref:`virtual environments <venv-def>`
172+
need to be handled.
167173
* :c:func:`!Py_GetProgramName`:
168174
use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
169175
(:data:`sys.executable`) instead.

Include/pylifecycle.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Py_DEPRECATED(3.11) PyAPI_FUNC(void) Py_SetPythonHome(const wchar_t *);
4040
Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void);
4141

4242
Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void);
43-
Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetPrefix(void);
4443
#ifdef MS_WINDOWS
4544
int _Py_CheckPython3(void);
4645
#endif

Lib/test/test_embed.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,6 @@ def test_getpath_abspath_win32(self):
17081708
def test_global_pathconfig(self):
17091709
# Test C API functions getting the path configuration:
17101710
#
1711-
# - Py_GetPrefix()
17121711
# - Py_GetProgramFullPath()
17131712
# - Py_GetPythonHome()
17141713
#
@@ -1722,13 +1721,11 @@ def get_func(name):
17221721
func.restype = ctypes.c_wchar_p
17231722
return func
17241723

1725-
Py_GetPrefix = get_func('Py_GetPrefix')
17261724
Py_GetProgramFullPath = get_func('Py_GetProgramFullPath')
17271725
Py_GetPythonHome = get_func('Py_GetPythonHome')
17281726

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

1731-
self.assertEqual(Py_GetPrefix(), config['prefix'])
17321729
self.assertEqual(Py_GetProgramFullPath(), config['executable'])
17331730
self.assertEqual(Py_GetPythonHome(), config['home'])
17341731

0 commit comments

Comments
 (0)