◐ Shell
clean mode source ↗

Message 74784 - Python tracker

Python3 skips environment variables which can not be parsed and 
decoded as unicode strings. But exec*() functions keep the original 
environment and so the child process environment is different than the 
Python environement (than os.environ).

I propose to remove these variables to avoid strange behaviours, but 
also to avoid possible security issues.

The attached patch is an implementation of this idea using a custom 
implementation of unsetenv(): _Py_unsetenv() argument is not the name 
of the variable but the raw variable including the value (eg. "a=b"). 
So it's also possible to drop truncated variables like "a" (no value 
nor "=" character).

This issue also affects Python2 since Python2 does also skip variable 
with no value but the variables still exist in memory (and so child 
process get them).