mirror of
https://github.com/pocketpy/pocketpy
synced 2026-02-04 06:30:17 +00:00
Problem: When an exception occurs in a WITH block, __exit__ was not called, preventing proper cleanup of context managers. Solution: 1. Wrap WITH block body in try-except structure 2. On normal exit: call __exit__(None, None, None) 3. On exception: call __exit__ with exception info before re-raising Changes: - compiler.c: Wrap WITH body in try-except, ensure __exit__ called in both paths - ceval.c: Update OP_WITH_EXIT to accept three arguments (exc_type, exc_val, exc_tb) - tests/520_context.py: Add test to verify __exit__ called on exceptions