You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the following lines of code, "dictionary changed size during iteration" would be thrown when the environment variables change while in iteration.
Python-3.5.0/Lib/urllib/request.py
2393 for name, value in os.environ.items():
2394 name = name.lower()
2395 if value and name[-6:] == '_proxy':
2396 proxies[name[:-6]] = value
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.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: