File: 0002-Handle-PEP-479-with-backward-compat-for-python2.7.patch

package info (click to toggle)
vcr.py 2.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 908 kB
  • sloc: python: 4,940; makefile: 180; sh: 17
file content (28 lines) | stat: -rw-r--r-- 1,105 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
From: =?utf-8?q?Pierre-Elliott_B=C3=A9cue?= <peb@debian.org>
Date: Wed, 17 Oct 2018 21:49:01 +0200
Subject: Handle PEP 479 with backward compat for python2.7

PEP479 renders the _handle_generator function of CassetteContextDecorator
object erroneous in python3.7. Yet, we can't rely properly on yield from
as python2.7 compat is still mandatory. Try to find a good balance
between these two facts
---
 vcr/cassette.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/vcr/cassette.py b/vcr/cassette.py
index 5683ddf..ae47cd8 100644
--- a/vcr/cassette.py
+++ b/vcr/cassette.py
@@ -136,7 +136,10 @@ class CassetteContextDecorator(object):
                 try:
                     to_send = yield to_yield
                 except Exception:
-                    to_yield = coroutine.throw(*sys.exc_info())
+                    try:
+                        to_yield = coroutine.throw(*sys.exc_info())
+                    except StopIteration:
+                        break
                 else:
                     try:
                         to_yield = coroutine.send(to_send)