mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.10] bpo-46009: Do not exhaust generator when send() method raises (GH-29986). (GH-29988)
* [3.10] bpo-46009: Do not exhaust generator when send() method raises (GH-29986).
(cherry picked from commit 69806b9516)
Co-authored-by: Mark Shannon <mark@hotpy.org>
* Rename variable after cherry-pick.
* Add NULL check.
This commit is contained in:
parent
cca3004f64
commit
99c72326d2
5 changed files with 30 additions and 21 deletions
|
|
@ -161,6 +161,14 @@ def f():
|
|||
with self.assertRaises((TypeError, pickle.PicklingError)):
|
||||
pickle.dumps(g, proto)
|
||||
|
||||
def test_send_non_none_to_new_gen(self):
|
||||
def f():
|
||||
yield 1
|
||||
g = f()
|
||||
with self.assertRaises(TypeError):
|
||||
g.send(0)
|
||||
self.assertEqual(next(g), 1)
|
||||
|
||||
|
||||
class ExceptionTest(unittest.TestCase):
|
||||
# Tests for the issue #23353: check that the currently handled exception
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue