[OE-core] [master][RFC] Adding back wrapper and using OEPYTHON3HOME variable for python3
richard.purdie at linuxfoundation.org
richard.purdie at linuxfoundation.org
Thu Apr 25 20:50:21 UTC 2019
On Thu, 2019-04-25 at 12:56 -0700, Jaewon Lee wrote:
> +diff --git a/Modules/main.c b/Modules/main.c
> +index a745381..25ca435 100644
> +--- a/Modules/main.c
> ++++ b/Modules/main.c
> +@@ -1857,6 +1857,11 @@ config_init_home(_PyCoreConfig *config)
> + }
> +
> + int res = config_get_env_var_dup(&home, L"PYTHONHOME", "PYTHONHOME");
> ++
> ++ const char *oepython3home = config_get_env_var("OEPYTHON3HOME");
> ++ if (oepython3home) {
> ++ res = config_get_env_var_dup(&home, L"OEPYTHON3HOME", "OEPYTHON3HOME");
> ++ }
> + if (res < 0) {
> + return DECODE_LOCALE_ERR("PYTHONHOME", res);
> + }
> +--
> +2.7.4
I think the above will leak memory.
Instead I think the code should be something like:
int res;
const char *oepython3home = config_get_env_var("OEPYTHON3HOME");
if (oepython3home) {
res = config_get_env_var_dup(&home, L"OEPYTHON3HOME", "OEPYTHON3HOME");
if (res < 0)
return DECODE_LOCALE_ERR("OEPYTHON3HOME", res);
} else {
res = config_get_env_var_dup(&home, L"PYTHONHOME", "PYTHONHOME");
if (res < 0)
return DECODE_LOCALE_ERR("PYTHONHOME", res);
}
and then a copy of PYTHONHOME isn't created in the OEPYTHON3HOME case.
Cheers,
Richard
More information about the Openembedded-core
mailing list