Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
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() andos.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