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)
