Skip to content
Myr

Avoid altering dictionary size during iteration, by gathering keys that need to be deleted first.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes `RuntimeError` on Python 3 introduced in 53ea23128e375ef84511fd2b22b740eca15d0854

authored by Martijn Pieters · committed by Martijn Pieters · parent c7c26fb · Browse files · 1 file+5 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−4 removed

  • other:+5 added−4 removed

1 file+5 added−4 removed

modified:requests/sessions.py+5 added-4 removed
60 unmodified lines
6162 merged_setting = dict_class(to_key_val_list(session_setting))63 merged_setting.update(to_key_val_list(request_setting))6465 # Remove keys that are set to None.66 for (k, v) in merged_setting.items():67 if v is None:68 del merged_setting[k]65 # Remove keys that are set to None. Extract keys first to avoid altering66 # the dictionary during iteration.67 none_keys = [k for (k, v) in merged_setting.items() if v is None]68 for key in none_keys:69 del merged_setting[key]7071 return merged_setting7273
609 unmodified lines