Commit Graph
11 Commits
Author SHA1 Message Date
Changjoon 3c7c4909c9 Chain __context__ alongside __cause__ when wrapping StopIteration (PEP 479) (#7731)
PEP 479 wraps a StopIteration raised from a generator/coroutine into a
RuntimeError. CPython sets both __cause__ and __context__ of the new
RuntimeError to the original StopIteration (the same object). RustPython's
wrapping sites set __cause__ only, leaving __context__ as None.

set___cause__ already toggles __suppress_context__ to true, so the
user-facing traceback is unchanged — only assertions that inspect
__context__ directly observe the gap.

Three sites all wrap StopIteration / StopAsyncIteration into RuntimeError
for PEP 479. Set __context__ to the same exception instance before
setting __cause__ at each:

- frame.rs::StopIterationError intrinsic (generator yield-expression path)
- coroutine.rs generator __next__ StopIteration branch
- coroutine.rs async-generator __anext__ StopAsyncIteration branch

PyBaseExceptionRef is Arc-backed, so e.clone() is a refcount bump;
'cause is context' holds, matching CPython.

Unmasks:
- test_generator_stop.TestPEP479.test_stopiteration_wrapping_context
- test_yield_from.TestInterestingEdgeCases.test_close_and_throw_work
- test_yield_from.TestInterestingEdgeCases.test_close_and_throw_raise_stop_iteration
- test_yield_from.TestInterestingEdgeCases.test_close_and_throw_yield
2026-04-29 18:52:22 +09:00
Jeong, YunWon 7abf8cc247 Bytecode parity - for-loop cleanup, return duplication, late jump threading fix (#7580)
- Use POP_TOP instead of POP_ITER for for-loop break/return cleanup
- Expand duplicate_end_returns to clone final return for jump predecessors
- Restrict late jump threading pass to unconditional jumps only
- Skip exception blocks in inline/reorder passes
- Simplify threaded_jump_instr NoInterrupt handling
2026-04-12 22:43:35 +09:00
ShaharNaveh 17b9986a6e Update test_yield_from.py from 3.14.3 2026-03-12 13:33:04 +01:00
Jeong, YunWon 25f545f059 apply tests
Assisted-by: Codex:gpt-6
2026-02-11 16:50:23 +09:00
Shahar Naveh 3c01be29c4 Update some tests to 3.13.7 (#6171)
* Update `test_call.py` from 3.13.7

* Update `test_yield_from.py` from 3.13.7

* Update more tests to 3.13.7

* More tests to 3.13.7

* Remove patch from passing test
2025-09-21 19:33:41 +09:00
CPython Developers 9571a68c01 Update test_yield_from from CPython 3.10.6 2022-08-14 23:50:53 +09:00
Taegi SongandNanHee Kim 12bbb79bad Fix define_exception! of PyStopIteration to set value of value attribute
Co-authored-by: NanHee Kim <kimnanhee0225@gmail.com>
2022-07-14 20:30:21 +09:00
Padraic Fanning 165df16945 Unmark passing tests due to CI limitations 2022-06-22 20:19:39 -04:00
Padraic Fanning 373aff3d69 Mark failing tests due to GitHub Actions 2021-08-08 13:23:37 -04:00
Padraic Fanning 60e36a08d5 Mark erroring/failing tests 2021-08-02 19:24:44 -04:00
Padraic Fanning f6aeb8bf09 Add test_yield_from from CPython 3.8 2021-08-02 19:24:43 -04:00