From b63d025135f0755bd5b1bd311146a88289305410 Mon Sep 17 00:00:00 2001 From: wanghao Date: Thu, 25 Jul 2019 16:58:28 +0800 Subject: [PATCH] Fit the StopIteration for py37 In Train we will switch to use py37 for tests. There is a breaking change between Python 3.6 and 3.7 that is making it an error to raise a StopIteration exception from a function or generator(https://www.python.org/dev/peps/pep-0479/). So we need to fix it in code. Change-Id: I003be4193944bc4176768c488f2f71b58fcbd58d Closes-Bug: #1837856 Story: #2005924 Task: #34258 --- .zuul.yaml | 2 +- setup.cfg | 2 ++ tox.ini | 2 +- zaqar/storage/mongodb/claims.py | 17 ++++++++++------- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index bbb710859..db97c29a7 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -112,7 +112,7 @@ - check-requirements - openstack-lower-constraints-jobs - openstack-python-jobs - - openstack-python36-jobs + - openstack-python3-train-jobs - periodic-stable-jobs - publish-openstack-docs-pti - release-notes-jobs-python3 diff --git a/setup.cfg b/setup.cfg index 48cba2a26..460912945 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,7 +15,9 @@ classifier = Programming Language :: Python Programming Language :: Python :: 2 Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 [files] packages = diff --git a/tox.ini b/tox.ini index 4a61a3593..e8446e292 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 2.0 -envlist = py36,py27,pep8 +envlist = py27,py37,pep8 skipsdist = True [testenv] diff --git a/zaqar/storage/mongodb/claims.py b/zaqar/storage/mongodb/claims.py index 234fd4639..42151cb29 100644 --- a/zaqar/storage/mongodb/claims.py +++ b/zaqar/storage/mongodb/claims.py @@ -38,15 +38,18 @@ LOG = logging.getLogger(__name__) def _messages_iter(msg_iter): """Used to iterate through messages.""" - msg = next(msg_iter) - yield msg.pop('claim') - yield msg - - # Smoke it! - for msg in msg_iter: - del msg['claim'] + try: + msg = next(msg_iter) + yield msg.pop('claim') yield msg + # Smoke it! + for msg in msg_iter: + del msg['claim'] + yield msg + except StopIteration: + return + class ClaimController(storage.Claim): """Implements claim resource operations using MongoDB.