Skip to content

Commit 2a561b5

Browse files
authored
bpo-37616: Handle version information more gracefully in getpath.c (GH-20214)
1 parent 2abeded commit 2a561b5

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

Modules/getpath.c

+3-9
Original file line numberDiff line numberDiff line change
@@ -1296,16 +1296,16 @@ calculate_zip_path(PyCalculatePath *calculate)
12961296
{
12971297
PyStatus res;
12981298

1299-
/* Path: <PLATLIBDIR> / "python00.zip" */
1300-
wchar_t *path = joinpath2(calculate->platlibdir_macro, L"python000.zip");
1299+
/* Path: <PLATLIBDIR> / "pythonXY.zip" */
1300+
wchar_t *path = joinpath2(calculate->platlibdir_macro, L"python" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION) L".zip");
13011301
if (path == NULL) {
13021302
return _PyStatus_NO_MEMORY();
13031303
}
13041304

13051305
if (calculate->prefix_found > 0) {
13061306
/* Use the reduced prefix returned by Py_GetPrefix()
13071307
1308-
Path: <basename(basename(prefix))> / <PLATLIBDIR> / "python000.zip" */
1308+
Path: <basename(basename(prefix))> / <PLATLIBDIR> / "pythonXY.zip" */
13091309
wchar_t *parent = _PyMem_RawWcsdup(calculate->prefix);
13101310
if (parent == NULL) {
13111311
res = _PyStatus_NO_MEMORY();
@@ -1325,12 +1325,6 @@ calculate_zip_path(PyCalculatePath *calculate)
13251325
goto done;
13261326
}
13271327

1328-
/* Replace "000" with the version */
1329-
size_t len = wcslen(calculate->zip_path);
1330-
calculate->zip_path[len - 7] = VERSION[0];
1331-
calculate->zip_path[len - 6] = VERSION[2];
1332-
calculate->zip_path[len - 5] = VERSION[3];
1333-
13341328
res = _PyStatus_OK();
13351329

13361330
done:

0 commit comments

Comments
 (0)