Unit test failure in Python 3.5: OrderedDict mutated during iteration

Bug #1565728 reported by Thomas Goirand
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
keystoneauth
Fix Released
Medium
Thomas Goirand

Bug Description

Yet another instance of this problem. This will come again until we have a Python 3.5 gate up and running. This time, the issue is in keystoneauth1/fixture/keystoneauth_betamax.py line 54:

- for scheme in session_obj.adapters.keys():
+ for scheme in list(session_obj.adapters.keys()):

I'm sending the patch for review.

Revision history for this message
Thomas Goirand (thomas-goirand) wrote :

Just FYI, as I expect someone to ask, here's the failures in Py 35:

======================================================================
FAIL: keystoneauth1.tests.unit.test_betamax_fixture.TestBetamaxFixture.test_keystoneauth_betamax_fixture
keystoneauth1.tests.unit.test_betamax_fixture.TestBetamaxFixture.test_keystoneauth_betamax_fixture
----------------------------------------------------------------------
_StringException: Traceback (most recent call last):
  File "/home/zigo/sources/openstack/mitaka/python-keystoneauth1/build-area/python-keystoneauth1-2.4.0/keystoneauth1/tests/unit/test_betamax_fixture.py", line 51, in test_keystoneauth_betamax_fixture
    self._replay_cassette()
  File "/home/zigo/sources/openstack/mitaka/python-keystoneauth1/build-area/python-keystoneauth1-2.4.0/keystoneauth1/tests/unit/test_betamax_fixture.py", line 47, in _replay_cassette
    s = session.Session()
  File "/usr/lib/python3/dist-packages/positional/__init__.py", line 94, in inner
    return func(*args, **kwargs)
  File "/home/zigo/sources/openstack/mitaka/python-keystoneauth1/build-area/python-keystoneauth1-2.4.0/keystoneauth1/session.py", line 149, in __init__
    self.session = _construct_session(session)
  File "/home/zigo/sources/openstack/mitaka/python-keystoneauth1/build-area/python-keystoneauth1-2.4.0/keystoneauth1/fixture/keystoneauth_betamax.py", line 54, in _construct_session_with_betamax
    for scheme in session_obj.adapters.keys():
RuntimeError: OrderedDict mutated during iteration

======================================================================
FAIL: keystoneauth1.tests.unit.test_betamax_fixture.TestBetamaxFixture.test_replay_of_bad_url_fails
keystoneauth1.tests.unit.test_betamax_fixture.TestBetamaxFixture.test_replay_of_bad_url_fails
----------------------------------------------------------------------
_StringException: Traceback (most recent call last):
  File "/home/zigo/sources/openstack/mitaka/python-keystoneauth1/build-area/python-keystoneauth1-2.4.0/keystoneauth1/tests/unit/test_betamax_fixture.py", line 59, in test_replay_of_bad_url_fails
    s = session.Session()
  File "/usr/lib/python3/dist-packages/positional/__init__.py", line 94, in inner
    return func(*args, **kwargs)
  File "/home/zigo/sources/openstack/mitaka/python-keystoneauth1/build-area/python-keystoneauth1-2.4.0/keystoneauth1/session.py", line 149, in __init__
    self.session = _construct_session(session)
  File "/home/zigo/sources/openstack/mitaka/python-keystoneauth1/build-area/python-keystoneauth1-2.4.0/keystoneauth1/fixture/keystoneauth_betamax.py", line 54, in _construct_session_with_betamax
    for scheme in session_obj.adapters.keys():
RuntimeError: OrderedDict mutated during iteration

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystoneauth (master)

Fix proposed to branch: master
Review: https://review.openstack.org/301049

Changed in keystoneauth:
assignee: nobody → Thomas Goirand (thomas-goirand)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystoneauth (master)

Reviewed: https://review.openstack.org/301049
Committed: https://git.openstack.org/cgit/openstack/keystoneauth/commit/?id=7dd4208e5c2519fa4647fd9f36b7f67bd2f11718
Submitter: Jenkins
Branch: master

commit 7dd4208e5c2519fa4647fd9f36b7f67bd2f11718
Author: Thomas Goirand <email address hidden>
Date: Mon Apr 4 13:02:08 2016 +0200

    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

Changed in keystoneauth:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystoneauth (stable/mitaka)

Fix proposed to branch: stable/mitaka
Review: https://review.openstack.org/301186

Changed in keystoneauth:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystoneauth (stable/mitaka)

Reviewed: https://review.openstack.org/301186
Committed: https://git.openstack.org/cgit/openstack/keystoneauth/commit/?id=73475f09e63647f82757a524b3bf2d82baf0dfd2
Submitter: Jenkins
Branch: stable/mitaka

commit 73475f09e63647f82757a524b3bf2d82baf0dfd2
Author: Thomas Goirand <email address hidden>
Date: Mon Apr 4 13:02:08 2016 +0200

    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
    (cherry picked from commit 7dd4208e5c2519fa4647fd9f36b7f67bd2f11718)

tags: added: in-stable-mitaka
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote : Fix included in openstack/keystoneauth 2.5.0

This issue was fixed in the openstack/keystoneauth 2.5.0 release.

Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/keystoneauth 2.4.1

This issue was fixed in the openstack/keystoneauth 2.4.1 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.