Closed
Description
os.putenv()
on Windows truncates a value containing an embedded null character.
>>> import os
>>> os.putenv('xyz', 'abc\0def')
>>> os.system('''python.bat -c "import os; print(repr(os.environ['xyz']))"''')
Running Debug|x64 interpreter...
'abc'
0
os.putenv()
and os.unsetenv()
also truncate a name. It leads to OSError because it truncates before "=".
>>> os.putenv('abc\0def', 'xyz')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
os.putenv('abc\0def', 'xyz')
OSError: [Errno 22] Invalid argument
>>> os.unsetenv('abc\0def')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
os.unsetenv('abc\0def')
OSError: [Errno 22] Invalid argument