sysconfig.get_config_vars()
values always get overwritten with the values from Makefile
#126920
Labels
sysconfig.get_config_vars()
values always get overwritten with the values from Makefile
#126920
Bug report
Bug description:
When fixing GH-126789, I noticed the
exec
andexec_prefix
keys fromsysconfig.get_config_vars()
always get set to the value fromMakefile
, instead of followingsys.prefix
andsys.exec_prefix
.This happens because, after we set the values from
sys.prefix
andsys.exec_prefix
insysconfig._init_config_vars()
,sysconfig._init_posix()
updates the dictionary with the values from theMakefile
, overwriting any values we set previously,cpython/Lib/sysconfig/__init__.py
Lines 469 to 470 in acbd5c9
cpython/Lib/sysconfig/__init__.py
Line 356 in acbd5c9
From my testing,
exec
andexec_prefix
seem to be only the only keys currently affected, and fortunately they aren't used to calculate any of thesysconfig.get_paths()
paths, which is probably why we didn't notice earlier.I should also note that since the
sys
values only differ from the ones in theMakefile
on virtual environments, this bug only happens inside virtual environments.That said, the current code makes things super fragile. Just creating a variable name
base
in theMakefile
, for eg., would majorly breaksysconfig.get_paths()
in virtual environments.The fix is pretty simple, the values from the
Makefile
should not overwrite any of the values we previously set.CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: