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

akira report at bugs.python.org
Fri Feb 28 06:02:09 CET 2014


akira added the comment:

Related: issue4926 "putenv() accepts names containing '=', return value of unsetenv() not checked" 

`os.environ.clear()` also fails if the environment contains names with `=`:

  >>> import os
  >>> os.environ['a=b'] = 'c'
  >>> os.environ.clear()
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/.../lib/python3.4/_collections_abc.py", line 558, in clear
      self.popitem()
    File "/.../lib/python3.4/_collections_abc.py", line 551, in popitem
      del self[key]
    File "/.../lib/python3.4/os.py", line 662, in __delitem__
      self.unsetenv(encodedkey)
  OSError: [Errno 22] Invalid argument

----------
nosy: +akira

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


More information about the Python-bugs-list mailing list