[issue20658] os.environ.clear() fails with empty keys (posix.unsetenv)

STINNER Victor report at bugs.python.org
Mon Aug 30 10:56:38 EDT 2021


STINNER Victor <vstinner at python.org> added the comment:

Attached set_unset_env.c program calls putenv("=hello world") and then unsetenv("").

On my Fedora 34 with glibc-2.33-20.fc34.x86_64, putenv() succeed, but unsetenv() fails.
---
$ gcc set_unset_env.c -g -o set_unset_env && ./set_unset_env
putenv("=hello world") -> hello world
ERROR: unsetenv("") failed: [error 22] Invalid argument
---

By the way, getenv() fails to find an environment variable if its name is empty: I reimplemented getenv() using the 'environ' variable for my test.

----------
Added file: https://bugs.python.org/file50245/set_unset_env.c

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue20658>
_______________________________________


More information about the Python-bugs-list mailing list