Skip to content

Commit 5304e49

Browse files
committed
remove Py_GetPath
1 parent 4e74756 commit 5304e49

File tree

18 files changed

+16
-73
lines changed

18 files changed

+16
-73
lines changed

Doc/c-api/init.rst

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +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_GetPath`,
81-
: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_GetPrefix`, :c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome`, :c:func:`PyEval_InitThreads`, and
8281
:c:func:`Py_RunMain`.
8382

8483

@@ -143,9 +142,6 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
143142
:c:member:`PyConfig.pathconfig_warnings` should be used instead, see
144143
:ref:`Python Initialization Configuration <init-config>`.
145144

146-
Suppress error messages when calculating the module search path in
147-
:c:func:`Py_GetPath`.
148-
149145
Private flag used by ``_freeze_module`` and ``frozenmain`` programs.
150146

151147
.. deprecated-removed:: 3.12 3.15
@@ -584,7 +580,6 @@ Process-wide parameters
584580
.. index::
585581
single: Py_Initialize()
586582
single: main()
587-
single: Py_GetPath()
588583
589584
This API is kept for backward compatibility: setting
590585
:c:member:`PyConfig.program_name` should be used instead, see :ref:`Python
@@ -594,7 +589,7 @@ Process-wide parameters
594589
the first time, if it is called at all. It tells the interpreter the value
595590
of the ``argv[0]`` argument to the :c:func:`main` function of the program
596591
(converted to wide characters).
597-
This is used by :c:func:`Py_GetPath` and some other functions below to find
592+
This is used by some other functions below to find
598593
the Python run-time libraries relative to the interpreter executable. The
599594
default value is ``'python'``. The argument should point to a
600595
zero-terminated wide character string in static storage whose contents will not
@@ -654,34 +649,6 @@ Process-wide parameters
654649
(:data:`sys.executable`) instead.
655650
656651
657-
.. c:function:: wchar_t* Py_GetPath()
658-
659-
.. index::
660-
triple: module; search; path
661-
single: path (in module sys)
662-
663-
Return the default module search path; this is computed from the program name
664-
(set by :c:member:`PyConfig.program_name`) and some environment variables.
665-
The returned string consists of a series of directory names separated by a
666-
platform dependent delimiter character. The delimiter character is ``':'``
667-
on Unix and macOS, ``';'`` on Windows. The returned string points into
668-
static storage; the caller should not modify its value. The list
669-
:data:`sys.path` is initialized with this value on interpreter startup; it
670-
can be (and usually is) modified later to change the search path for loading
671-
modules.
672-
673-
This function should not be called before :c:func:`Py_Initialize`, otherwise
674-
it returns ``NULL``.
675-
676-
.. XXX should give the exact rules
677-
678-
.. versionchanged:: 3.10
679-
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
680-
681-
.. deprecated-removed:: 3.13 3.15
682-
Use :c:func:`PyConfig_Get("module_search_paths") <PyConfig_Get>`
683-
(:data:`sys.path`) instead.
684-
685652
.. c:function:: const char* Py_GetVersion()
686653
687654
Return the version of this Python interpreter. This is a string that looks

Doc/c-api/intro.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,6 @@ 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_GetPath (C function)
784783
single: Py_GetPrefix (C function)
785784
single: Py_GetProgramFullPath (C function)
786785

@@ -789,8 +788,7 @@ The embedding application can steer the search by setting
789788
:c:func:`Py_InitializeFromConfig`. Note that
790789
:envvar:`PYTHONHOME` still overrides this and :envvar:`PYTHONPATH` is still
791790
inserted in front of the standard path. An application that requires total
792-
control has to provide its own implementation of :c:func:`Py_GetPath`,
793-
:c:func:`Py_GetPrefix`, and
791+
control has to provide its own implementation of :c:func:`Py_GetPrefix`, and
794792
:c:func:`Py_GetProgramFullPath` (all defined in :file:`Modules/getpath.c`).
795793

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

Doc/data/refcounts.dat

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3007,8 +3007,6 @@ Py_GetCompiler:const char*:::
30073007

30083008
Py_GetCopyright:const char*:::
30093009

3010-
Py_GetPath:wchar_t*:::
3011-
30123010
Py_GetPlatform:const char*:::
30133011

30143012
Py_GetPrefix:wchar_t*:::

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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +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_GetPath`:
26-
Use :c:func:`PyConfig_Get("module_search_paths") <PyConfig_Get>`
27-
(:data:`sys.path`) instead.
2825
* :c:func:`Py_GetPrefix`:
2926
Use :c:func:`PyConfig_Get("base_prefix") <PyConfig_Get>`
3027
(:data:`sys.base_prefix`) instead. Use :c:func:`PyConfig_Get("prefix")

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
@@ -2479,7 +2479,7 @@ Deprecated C APIs
24792479
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.
24802480
* :c:func:`!Py_GetExecPrefix`:
24812481
Get :data:`sys.exec_prefix` instead.
2482-
* :c:func:`Py_GetPath`:
2482+
* :c:func:`!Py_GetPath`:
24832483
Get :data:`sys.path` instead.
24842484
* :c:func:`Py_GetPrefix`:
24852485
Get :data:`sys.prefix` instead.

Doc/whatsnew/3.15.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ Removed C APIs
161161
Use :c:func:`PyConfig_Get("exec_prefix") <PyConfig_Get>`
162162
(:data:`sys.exec_prefix`) if :ref:`virtual environments <venv-def>`
163163
need to be handled.
164+
* :c:func:`!Py_GetPath`:
165+
use :c:func:`PyConfig_Get("module_search_paths") <PyConfig_Get>`
166+
(:data:`sys.path`) instead.
164167
* :c:func:`!Py_GetProgramName`:
165168
use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
166169
(:data:`sys.executable`) instead.

Include/pylifecycle.h

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

4242
Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void);
4343
Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetPrefix(void);
44-
Py_DEPRECATED(3.13) PyAPI_FUNC(wchar_t *) Py_GetPath(void);
4544
#ifdef MS_WINDOWS
4645
int _Py_CheckPython3(void);
4746
#endif

Lib/test/test_embed.py

Lines changed: 0 additions & 4 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_GetPath()
17121711
# - Py_GetPrefix()
17131712
# - Py_GetProgramFullPath()
17141713
# - Py_GetPythonHome()
@@ -1723,15 +1722,12 @@ def get_func(name):
17231722
func.restype = ctypes.c_wchar_p
17241723
return func
17251724

1726-
Py_GetPath = get_func('Py_GetPath')
17271725
Py_GetPrefix = get_func('Py_GetPrefix')
17281726
Py_GetProgramFullPath = get_func('Py_GetProgramFullPath')
17291727
Py_GetPythonHome = get_func('Py_GetPythonHome')
17301728

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

1733-
self.assertEqual(tuple(Py_GetPath().split(os.path.pathsep)),
1734-
config['module_search_paths'])
17351731
self.assertEqual(Py_GetPrefix(), config['prefix'])
17361732
self.assertEqual(Py_GetProgramFullPath(), config['executable'])
17371733
self.assertEqual(Py_GetPythonHome(), config['home'])

0 commit comments

Comments
 (0)