Commit Graph
81 Commits
Author SHA1 Message Date
Shahar Naveh ea352ccdae Make inner oparg values private (#7050) 2026-02-08 14:56:56 +00:00
Jeong, YunWon 5dabad6702 reason inside #[allow] (#7049) 2026-02-08 13:11:50 +00:00
Shahar Naveh c8b4d6308f Newtype for LoadAttr oparg (#7047) 2026-02-08 11:47:14 +00:00
Jeong, YunWon 07fc6ee3c7 no_std clippy (#7043) 2026-02-08 16:49:18 +09:00
Shahar Naveh f817ab8d07 Bytecode oparg optimization (#7032)
* Generate optimized oparg enums

* No need to match on 255

* Remove `num_enum` crate from `compiler-core`

* Update `Cargo.lock`

* macro fmt

* Rename macro vars

* Match without `,`

* Support alternative values

* Fix alternatives

* Improve docs

* Add const assert

* Don't use `as u32`

* Make only ComparisonOperator unoptimized

* Fix test

* cleanup

* All opargs are optimized

* Remove comment
2026-02-07 19:15:16 +09:00
Jeong, YunWonandCPython Developers 6b870d62ad Fix traceback, syntax errors, and exception handling (#7015)
* Update codeop from v3.14.3

* Fix traceback, syntax errors, and exception handling

- Improve unclosed bracket detection with "'(' was never closed" message
- Fix IndentationError location to point to end of line
- Implement frame.clear() with proper checks for executing/suspended frames
- Fix exception context chaining for propagated exceptions
- Add traceback.__dir__() and prevent tb_next deletion
- Fix subscript operation source range restoration in compiler
- Change "duplicate parameter" to "duplicate argument" error message
- Refactor duplicate code in asyncgenerator.rs and frame.rs

---------

Co-authored-by: CPython Developers <>
2026-02-07 13:41:45 +09:00
Jeong, YunWon 6de6a92717 Merge pull request #7001 from youknowone/annotationlib
Add test_annotationlib to v3.14.2 and fix related bugs
2026-02-05 23:39:47 +09:00
Jeong, YunWon 535638e1e7 Fix annotationlib parsing 2026-02-05 22:46:23 +09:00
Shahar Naveh 5b7db1d2d2 Newtype LoadSuperAttr oparg (#7002) 2026-02-05 21:14:38 +09:00
Jeong, YunWon ff49bfe3a7 mark ast & test_genericalias 2026-02-03 14:16:10 +09:00
Jeong, YunWon 1876ac88e0 Fix compiler panics 2026-02-03 14:16:10 +09:00
Jeong, YunWon 0da5931353 fix unparse 2026-02-03 14:16:10 +09:00
Jeong, YunWon cdadde55ef Update faulthandler to match CPython 3.14.2
- Rewrite faulthandler with live frame walking via
  Frame.previous AtomicPtr chain and thread-local
  CURRENT_FRAME (AtomicPtr) instead of frame snapshots
- Add signal-safe traceback dumping (dump_live_frames,
  dump_frame_from_raw) walking the Frame.previous chain
- Add safe_truncate/dump_ascii for UTF-8 safe string
  truncation in signal handlers
- Refactor write_thread_id to accept thread_id parameter
- Add SA_RESTART for user signal registration, SA_NODEFER
  only when chaining
- Save/restore errno in faulthandler_user_signal
- Add signal re-entrancy guard in trigger_signals to
  prevent recursive handler invocation
- Add thread frame tracking (push/pop/cleanup/reinit)
  with force_unlock fallback for post-fork recovery
- Remove expectedFailure markers for now-passing tests
2026-02-03 13:41:58 +09:00
Jeong, YunWon f7b2660882 Fix test_asyncio for windows (#6959) 2026-02-02 15:58:16 +09:00
Jeong, YunWon 153b0da60d automark add reasons to reason-less expectedFailures and handles parent better (#6936) 2026-02-01 22:58:07 +09:00
Jeong, YunWon 97861c6809 Rework exception compiler to use CFG-based handler analysis (#6909)
Move exception handler tracking from compile-time fblock metadata to
a post-codegen CFG analysis pass, matching flowgraph.c's pipeline.

Compiler changes (compile.rs):
- Remove fb_handler, fb_stack_depth, fb_preserve_lasti from FBlockInfo
- Remove handler_stack_depth() and current_except_handler() helpers
- Emit SetupFinally/SetupCleanup/SetupWith/PopBlock pseudo instructions
  instead of manually tracking handlers in fblocks
- Add dead blocks after raise/break/continue/return to prevent
  dead code from corrupting the except stack
- Add missing PopTop after CallIntrinsic1 ImportStar
- Fix async comprehension SetupFinally/GetANext emission order
- Fix try-except* handler: move BUILD_LIST/COPY before handler loop
- Rework unwind_fblock for HandlerCleanup, TryExcept, FinallyTry,
  FinallyEnd, and With/AsyncWith to emit proper PopBlock sequences

New CFG analysis passes (ir.rs):
- mark_except_handlers(): mark blocks targeted by SETUP_* instructions
- label_exception_targets(): walk CFG with except stack to set
  per-instruction handler info and convert POP_BLOCK to NOP
- convert_pseudo_ops(): lower remaining pseudo ops after analysis
- Compute handler entry depth from SETUP_* type in max_stackdepth()
  (SETUP_CLEANUP=+2, SETUP_FINALLY/SETUP_WITH=+1)
- Fix SEND jump_effect from -1 to 0 (receiver stays until END_SEND)
- Add underflow guard for handler stack_depth calculation

Instruction metadata (instruction.rs):
- SetupCleanup/SetupFinally/SetupWith now carry target: Arg<Label>
- Add is_block_push()/is_pop_block() to PseudoInstruction/AnyInstruction
- Fix LoadSpecial stack_effect from (2,2) to (1,1)
- Set Setup* stack_effect_info to (0,0) for fall-through consistency

Fixes 3 test_coroutines expectedFailures:
- test_with_8, test_for_assign_raising_stop_async_iteration{,_2}
2026-02-01 17:53:57 +09:00
Shahar Naveh c771427c38 Use stack_effect_info for getting pop&push count (#6913) 2026-01-31 23:45:46 +09:00
Shahar Naveh 743d6b83d3 Split stack_effect into pushed & popped (#6893) 2026-01-31 16:58:14 +09:00
Jeong, YunWon 8e9d591369 Align GetAwaitable to Python 3.14.2 (#6895) 2026-01-30 12:13:39 +09:00
Jeong, YunWon 95abec4c21 More Load instructions including LoadLocals, LoadFastBorrow (#6886)
* fix stdlib_io

* more scpell dict

* LoadLocals

* LoadFastBorrow

* more ops
2026-01-29 19:33:46 +09:00
Jeong YunWon 8c73f3cb30 emit RESUME 2026-01-26 10:40:22 +09:00
Jeong YunWon 9216500355 reimpl smallint 2026-01-26 10:40:22 +09:00
Jeong, YunWon 7eceb145b1 more optimization (#6860) 2026-01-25 10:18:47 +02:00
Jeong YunWon c0bdb9a3e5 align psuedo ops to 3.14.2 2026-01-24 16:09:40 +09:00
Noa f842fbe25d Use std::fmt::from_fn (#6850)
New in 1.93 - replaces our ad-hoc equivalent types.
2026-01-24 09:21:45 +09:00
Jeong, YunWon af7bbfa104 derive Copy where possible (#6844)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Made many lightweight/internal types trivially copyable to simplify
value handling across the codebase.
* Added a workspace lint to surface missing copy implementations as
warnings.
  * Extended buffer support with explicit retain/release hooks.

* **Bug Fixes**
* Improved diagnostics and debug output for thread/lock acquisition
scenarios.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-01-23 15:24:17 +00:00
ShaharNaveh 2c2b13784e Clippy 2026-01-23 16:41:24 +02:00
ShaharNaveh a9364cbc52 Fix warnings 2026-01-23 16:41:19 +02:00
ShaharNaveh 2ee48bc5aa Seperate between scope exit & unconditional jump opcodes 2026-01-23 14:25:03 +02:00
Jeong, YunWon efce325cbf Fix asyncio related compiler/library issues (#6837)
* Fix socket bytes support

* fix unwind_fblock

* fix posix.sendfile

* fix ssl_write

* Fix SSL ZeroReturn

* fix context

* fix generator

* Enable unittest test_async_case again
2026-01-23 19:59:29 +09:00
Jeong, YunWon 40a43f3210 instruction improvements (#6829)
New Features

Direct small-integer loading (0–255) and locals-loading for faster execution
Async-generator wrapping and improved generator resume behavior
Performance

Faster integer loads and streamlined jump/loop handling for better runtime performance
Bug Fixes

More robust StopIteration handling and stricter init return checks
Corrected iterator cleanup for async and sync loops
Improvements

Aligns loop and jump semantics with CPython 3.14 patterns
2026-01-22 17:25:56 +09:00
Jeong, YunWon a7f2351244 Remove BEFORE_WITH,BINARY_SUBSCR (#6822) 2026-01-21 02:58:24 +09:00
Jeong, YunWon 274e8b4b6b Remove JUMP_IF_NOT_EXC_MATCH, SET_EXC_INFO (#6820) 2026-01-21 01:23:43 +09:00
Jeong, YunWon e0cceaf31c Remove ReturnConst/Break/Continue ops (#6816)
* Remove ReturnConst

* Remove break/continue ops
2026-01-21 00:03:43 +09:00
Jeong, YunWon f0c3e7d51f Remove SUBSCRIPT, JUMP_IF_{TRUE,FALSE}_OR_POP (#6810)
* Align ForIter behavior (incomplete)

* Romove JUMP_IF_{TRUE,FALSE}_OR_POP, subscript

* Remove LoadAssetionError

* Update snapshot for ForIter behavior change
2026-01-20 16:21:23 +09:00
Jeong, YunWonandgithub-actions[bot] 82a8f67c71 Replace custom opcodes with CPython standard sequences (#6794)
* Replace custom opcodes with standard sequences

Remove RustPython-specific opcodes (BuildListFromTuples,
BuildMapForCall, BuildSetFromTuples, BuildTupleFromTuples)
and replace their usage with CPython 3.14 standard opcode
sequences:

- BuildListFromTuples → BUILD_LIST + LIST_EXTEND loop
- BuildSetFromTuples → BUILD_SET + SET_UPDATE loop
- BuildTupleFromTuples → BUILD_LIST + LIST_EXTEND + CALL_INTRINSIC_1(ListToTuple)
- BuildMapForCall → DICT_MERGE loop

Implement missing opcodes:
- ListExtend: Extend list with iterable elements
- SetUpdate: Add iterable elements to set
- DictMerge: Merge dict with duplicate key checking

* Auto-generate: generate_opcode_metadata.py

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-01-20 00:34:46 +09:00
Jeong, YunWon 130bb82a43 LoadClosure as pseudo op (#6789) 2026-01-19 02:45:00 +09:00
Jeong, YunWon 0717b53123 Align CallFunctionEx to 3.14 (#6786) 2026-01-19 00:37:18 +09:00
Jeong, YunWon 1ccd99ea20 use ast namespace (#6769) 2026-01-18 17:30:36 +09:00
Jeong, YunWon eb50246b41 fix annotation (#6767) 2026-01-18 15:24:17 +09:00
Jeong, YunWon 6df3753229 Py 3.14 changes fix (#6755)
* marshal v5

* conditional blclk

* fix jit don't use lossy string

* add varname

* symboltable takes responsibility of __debug__
2026-01-18 01:02:40 +09:00
Jeong, YunWon faeed2cdcc clean up 2026-01-17 19:22:18 +09:00
Jeong, YunWon 566b6f438b PEP 649 annotation phase 4 2026-01-17 19:21:11 +09:00
Jeong, YunWon a78b569d92 PEP 649 annotation phase 3 2026-01-17 19:21:11 +09:00
Jeong, YunWon 353a9f6104 PEP 649 annotation phase 2 2026-01-17 19:21:11 +09:00
Jeong, YunWon 0793bd3d08 co_consts 2026-01-17 19:21:11 +09:00
Jeong, YunWon f4363a6b27 PEP 750 tstring (#6744) 2026-01-17 18:41:40 +09:00
Jeong, YunWon a0ace054f3 Fix asyncio compile (#6739) 2026-01-16 09:12:16 +09:00
Shahar Naveh e3890f9b4a Bytecode pseudo opcodes (#6715) 2026-01-15 02:52:25 +09:00
Jeong, YunWon 29bb8b47cd Super instructions (#6694)
* super instructions

* Fix classcell

* ZeroArg
2026-01-11 17:59:32 +09:00