Fix py37 compatibility

Unit tests are failing under python3.7.
Generators which explicitly raise StopIteration can generally be
changed to simply return instead. This will be compatible with
all existing Python versions.

PEP Documentation for this change:
https://www.python.org/dev/peps/pep-0479/

Change-Id: I4ae2049d8a2469d0a37077bdc722481e68d7cc49
Closes-Bug: #1814890
This commit is contained in:
Michal Arbet 2019-02-06 14:11:07 +01:00
parent b4120a1352
commit 5deb538930
1 changed files with 5 additions and 2 deletions

View File

@ -406,7 +406,10 @@ class ResponseBodyIterator(object):
def __iter__(self):
while True:
yield self.next()
try:
yield self.next()
except StopIteration:
return
def __bool__(self):
return hasattr(self, 'items')
@ -418,7 +421,7 @@ class ResponseBodyIterator(object):
if chunk:
return chunk
else:
raise StopIteration()
raise StopIteration
def _construct_http_client(*args, **kwargs):