Skip to content

Commit 93865e6

Browse files
committed
Update test_yield_from.py from 3.14.3
1 parent 8530439 commit 93865e6

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

Lib/test/test_yield_from.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ def g():
538538
"finishing g",
539539
])
540540

541-
@unittest.expectedFailure # TODO: RUSTPYTHON
541+
@unittest.expectedFailure # TODO: RUSTPYTHON
542542
def test_broken_getattr_handling(self):
543543
"""
544544
Test subiterator with a broken getattr implementation
@@ -882,7 +882,7 @@ def g():
882882
yield from ()
883883
self.assertRaises(StopIteration, next, g())
884884

885-
@unittest.expectedFailure # TODO: RUSTPYTHON
885+
@unittest.expectedFailure # TODO: RUSTPYTHON
886886
def test_delegating_generators_claim_to_be_running(self):
887887
# Check with basic iteration
888888
def one():
@@ -909,7 +909,7 @@ def two():
909909
pass
910910
self.assertEqual(res, [0, 1, 2, 3])
911911

912-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Lists differ: [0, 1, 2] != [0, 1, 2, 3]
912+
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: Lists differ: [0, 1, 2] != [0, 1, 2, 3]
913913
def test_delegating_generators_claim_to_be_running_with_throw(self):
914914
# Check with throw
915915
class MyErr(Exception):
@@ -1071,7 +1071,7 @@ def assert_generator_raised_stop_iteration(self):
10711071
def assert_generator_ignored_generator_exit(self):
10721072
return self.assertRaisesRegex(RuntimeError, r"^generator ignored GeneratorExit$")
10731073

1074-
@unittest.expectedFailure # TODO: RUSTPYTHON
1074+
@unittest.expectedFailure # TODO: RUSTPYTHON
10751075
def test_close_and_throw_work(self):
10761076

10771077
yielded_first = object()
@@ -1209,7 +1209,7 @@ def outer():
12091209
self.assertIsNone(caught.exception.__context__.__context__)
12101210
self.assert_stop_iteration(g)
12111211

1212-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: RuntimeError not raised
1212+
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: RuntimeError not raised
12131213
def test_close_and_throw_raise_stop_iteration(self):
12141214

12151215
yielded_first = object()
@@ -1449,7 +1449,7 @@ def outer():
14491449
self.assertIsNone(caught.exception.__context__.__context__)
14501450
self.assert_stop_iteration(g)
14511451

1452-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: None is not StopIteration()
1452+
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: None is not StopIteration()
14531453
def test_close_and_throw_yield(self):
14541454

14551455
yielded_first = object()
@@ -1531,8 +1531,9 @@ def inner():
15311531
try:
15321532
yield yielded_first
15331533
yield yielded_second
1534-
finally:
1535-
return returned
1534+
except:
1535+
pass
1536+
return returned
15361537

15371538
def outer():
15381539
return (yield from inner())
@@ -1587,6 +1588,19 @@ def outer():
15871588
self.assertIsNone(caught.exception.__context__)
15881589
self.assert_stop_iteration(g)
15891590

1591+
def test_throws_in_iter(self):
1592+
# See GH-126366: NULL pointer dereference if __iter__
1593+
# threw an exception.
1594+
class Silly:
1595+
def __iter__(self):
1596+
raise RuntimeError("nobody expects the spanish inquisition")
1597+
1598+
def my_generator():
1599+
yield from Silly()
1600+
1601+
with self.assertRaisesRegex(RuntimeError, "nobody expects the spanish inquisition"):
1602+
next(iter(my_generator()))
1603+
15901604

15911605
if __name__ == '__main__':
15921606
unittest.main()

0 commit comments

Comments
 (0)