Browse Source

fix OrderedDict mutated during iteration

Running unit tests of keystoneauth in Python 3.5 reveals the issue
that in Python 3.5+, keys() is not a copy, and therefore items can't
be popped from it while iterating.

This patch iterate over copy of session.adapters keys in Python2/3.

Change-Id: I4a4340d6f0b09e047e992d0a7236f83ff5eac7a3
Closes-Bug: #1565728
Thomas Goirand 3 years ago
parent
commit
7dd4208e5c
1 changed files with 1 additions and 1 deletions
  1. 1
    1
      keystoneauth1/fixture/keystoneauth_betamax.py

+ 1
- 1
keystoneauth1/fixture/keystoneauth_betamax.py View File

@@ -51,7 +51,7 @@ def _construct_session_with_betamax(fixture, session_obj=None):
51 51
     if not session_obj:
52 52
         session_obj = requests.Session()
53 53
         # Use TCPKeepAliveAdapter to fix bug 1323862
54
-        for scheme in session_obj.adapters.keys():
54
+        for scheme in list(session_obj.adapters.keys()):
55 55
             session_obj.mount(scheme, session.TCPKeepAliveAdapter())
56 56
     fixture.recorder = betamax.Betamax(
57 57
         session_obj, cassette_library_dir=fixture.cassette_library_dir)

Loading…
Cancel
Save