File: fix-py37-stopiteration.patch

package info (click to toggle)
python-zunclient 2.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 896 kB
  • sloc: python: 8,303; sh: 168; makefile: 31
file content (28 lines) | stat: -rw-r--r-- 1,009 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Description: Catch the raise of StopIteration with return.
 PEP 0479, https://www.python.org/dev/peps/pep-0479/, makes
 the following change: "when StopIteration is raised inside
 a generator, it is replaced it with RuntimeError". And states:
 "If raise StopIteration occurs directly in a generator,
 simply replace it with return."
Author: Hongbin Lu <hongbin034@gmail.com>
Date: Sun, 05 Aug 2018 22:54:53 +0000
Change-Id: Ib751b680b7357782cb5359526e1e83ee8c5c80dd
Origin: upstream, https://review.openstack.org/#/c/588995/
Last-Update: 2018-08-21

diff --git a/zunclient/common/httpclient.py b/zunclient/common/httpclient.py
index f4802ff..5f89439 100644
--- a/zunclient/common/httpclient.py
+++ b/zunclient/common/httpclient.py
@@ -395,7 +395,10 @@
 
     def __iter__(self):
         while True:
-            yield self.next()
+            try:
+                yield self.next()
+            except StopIteration:
+                return
 
     def next(self):
         chunk = self.resp.read(CHUNKSIZE)