[issue25641] urllib/request.py/getproxies_environment() throws "dictionary changed size during iteration" error occasionally

Senthil Kumaran report at bugs.python.org
Sun Jan 3 21:40:13 EST 2016


Senthil Kumaran added the comment:

os.environ is never changed by getproxies_environment()

Like Martin Panter, I will curious to know as how the user experienced this issue in the place.

@Raymond Hettinger: If the dict is only read and never modified in the fuction, does it still make sense to have a defensive list() as you suggested? If yes, then there will be couple of places in the stdlib code that will need this change.

```
$ ag os.environ.items Lib
Lib/distutils/_msvccompiler.py
80:            for key, value in os.environ.items()

Lib/test/test_os.py
679:        for key, val in os.environ.items():

Lib/test/test_wsgiref.py
427:    os_environ = dict(os.environ.items())

Lib/urllib/request.py
2453:    for name, value in os.environ.items():

Lib/wsgiref/handlers.py
47:    for k, v in os.environ.items():
```

My understanding is, if the function is not manipulation and only reading the dictionary, a defensive list or copy is not required. And, this bug report should be closed.

----------
nosy: +orsenthil
status: open -> pending

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


More information about the Python-bugs-list mailing list