summaryrefslogtreecommitdiffstats
path: root/Modules/getpath.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-06-11 15:28:52 (GMT)
committerGitHub <noreply@github.com>2020-06-11 15:28:52 (GMT)
commitd72b9644a3e6eec83be48b1ebc2ec6ca776134d3 (patch)
tree5ea7e7aa01e7f10f35d8b70837c73a81d29e8e75 /Modules/getpath.c
parentb2dca49ca3769cb60713f5c2b43e5d5bbdc1f9c7 (diff)
downloadcpython-d72b9644a3e6eec83be48b1ebc2ec6ca776134d3.zip
cpython-d72b9644a3e6eec83be48b1ebc2ec6ca776134d3.tar.gz
cpython-d72b9644a3e6eec83be48b1ebc2ec6ca776134d3.tar.bz2
bpo-40947: getpath.c uses PyConfig.platlibdir (GH-20807)
Followup of bpo-40854, there is one remaining usage of PLATLIBDIR which should be replaced by config->platlibdir. test_sys checks that sys.platlibdir attribute exists and is a string. Update Makefile: getpath.c and sysmodule.c no longer need PLATLIBDIR macro, PyConfig.platlibdir member is used instead. Co-authored-by: Sandro Mani <manisandro@gmail.com>
Diffstat (limited to 'Modules/getpath.c')
-rw-r--r--Modules/getpath.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 469c9ca..f7a6dd4 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -130,7 +130,7 @@ typedef struct {
wchar_t *exec_prefix_macro; /* EXEC_PREFIX macro */
wchar_t *vpath_macro; /* VPATH macro */
- wchar_t *lib_python; /* "lib/pythonX.Y" */
+ wchar_t *lib_python; /* <platlibdir> / "pythonX.Y" */
int prefix_found; /* found platform independent libraries? */
int exec_prefix_found; /* found the platform dependent libraries? */
@@ -810,7 +810,7 @@ calculate_exec_prefix(PyCalculatePath *calculate, _PyPathConfig *pathconfig)
"Could not find platform dependent libraries <exec_prefix>\n");
}
- /* <PLATLIBDIR> / "lib-dynload" */
+ /* <platlibdir> / "lib-dynload" */
wchar_t *lib_dynload = joinpath2(calculate->platlibdir,
L"lib-dynload");
if (lib_dynload == NULL) {
@@ -1296,8 +1296,10 @@ calculate_zip_path(PyCalculatePath *calculate)
{
PyStatus res;
- /* Path: <PLATLIBDIR> / "pythonXY.zip" */
- wchar_t *path = joinpath2(calculate->platlibdir, L"python" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION) L".zip");
+ /* Path: <platlibdir> / "pythonXY.zip" */
+ wchar_t *path = joinpath2(calculate->platlibdir,
+ L"python" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION)
+ L".zip");
if (path == NULL) {
return _PyStatus_NO_MEMORY();
}
@@ -1305,7 +1307,7 @@ calculate_zip_path(PyCalculatePath *calculate)
if (calculate->prefix_found > 0) {
/* Use the reduced prefix returned by Py_GetPrefix()
- Path: <basename(basename(prefix))> / <PLATLIBDIR> / "pythonXY.zip" */
+ Path: <basename(basename(prefix))> / <platlibdir> / "pythonXY.zip" */
wchar_t *parent = _PyMem_RawWcsdup(calculate->prefix);
if (parent == NULL) {
res = _PyStatus_NO_MEMORY();
@@ -1426,6 +1428,11 @@ static PyStatus
calculate_init(PyCalculatePath *calculate, const PyConfig *config)
{
size_t len;
+
+ calculate->warnings = config->pathconfig_warnings;
+ calculate->pythonpath_env = config->pythonpath_env;
+ calculate->platlibdir = config->platlibdir;
+
const char *path = getenv("PATH");
if (path) {
calculate->path_env = Py_DecodeLocale(path, &len);
@@ -1452,14 +1459,16 @@ calculate_init(PyCalculatePath *calculate, const PyConfig *config)
return DECODE_LOCALE_ERR("VPATH macro", len);
}
- calculate->lib_python = Py_DecodeLocale(PLATLIBDIR "/python" VERSION, &len);
- if (!calculate->lib_python) {
+ // <platlibdir> / "pythonX.Y"
+ wchar_t *pyversion = Py_DecodeLocale("python" VERSION, &len);
+ if (!pyversion) {
return DECODE_LOCALE_ERR("VERSION macro", len);
}
-
- calculate->warnings = config->pathconfig_warnings;
- calculate->pythonpath_env = config->pythonpath_env;
- calculate->platlibdir = config->platlibdir;
+ calculate->lib_python = joinpath2(config->platlibdir, pyversion);
+ PyMem_RawFree(pyversion);
+ if (calculate->lib_python == NULL) {
+ return _PyStatus_NO_MEMORY();
+ }
return _PyStatus_OK();
}