28 Commits

Author SHA1 Message Date
Jeong, YunWon
d3272e752b Align codegen metadata with CPython (#7952) 2026-05-23 20:16:03 +09:00
Jeong, YunWon
62b081b893 Resolve test_inspect bytecode parity gaps (#7926)
* Resolve test_inspect bytecode parity gaps

* Address code review feedback
2026-05-19 22:47:58 +09:00
Jeong, YunWon
9140ef583a Bytecode parity - boolop, comprehension, CFG passes (#7631)
* Bytecode parity - boolop, comprehension, CFG passes

- Flatten nested same-op BoolOp and add IfExpr to jump_if
- Simplify is_name_imported to module-level only
- Enable inlined comprehensions in module/class scope
- Add TweakInlinedComprehensionScopes with fast_hidden tracking
- Track fb_range in FBlockInfo for with-statement line info
- Add constant subscript folding and unary Not folding
- Add emit_return_const_no_location for implicit returns
- Use JumpNoInterrupt for ternary/except jumps
- Add STACK_USE_GUIDELINE threshold for collection building
- Reorder CFG pipeline: inline small blocks earlier, resolve
  line numbers before cold block extraction
- Add redirect_empty_unconditional_jump_targets,
  reorder_conditional_chain_and_jump_back_blocks,
  materialize_empty_conditional_exit_targets,
  duplicate_shared_jump_back_targets passes
- Add borrow deoptimization for multi-handler, named-except,
  protected conditional tail, and protected import joins
- Run folding/optimization passes twice around peephole

* Bytecode parity - slice augassign, async comp inline

- Augmented assignment with two-part slices uses BINARY_SLICE/STORE_SLICE
- Inline async comprehensions (remove await/async guards)
- Inlined comprehension cleanup jump uses JumpNoInterrupt
- Class firstlineno uses first decorator line when decorated
- Recurse into nested functions for static attribute collection
- Fold unary positive complex constants (+0.0j)
- Add deoptimize_borrow_for_folded_nonliteral_exprs pass
- Add inline_single_predecessor_artificial_expr_exit_blocks pass
- Skip shared artificial expr-stmt exit blocks in small-block inlining
- Mark folded boolop tail as folded_from_nonliteral_expr

* apply reviews
2026-04-21 00:10:00 +09:00
Shahar Naveh
7b5ac61026 Update some libs and tests from 3.14.3 to 3.14.4 (#7576)
* Update some libs and tests to 3.14.4

* Update `pydoc_data`
2026-04-10 09:16:10 +09:00
Copilot
902985def7 Fix inspect.getsource returning truncated source for multi-line function definitions (#7519)
* Initial plan

* fix: restore def-line source range before entering function scope so co_firstlineno is correct

Agent-Logs-Url: https://github.com/RustPython/RustPython/sessions/94701403-2011-4525-88f1-6e06891da6a4

Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>

* fix: remove pre-existing expectedFailure decorators from test_gettext plural form tests

Agent-Logs-Url: https://github.com/RustPython/RustPython/sessions/ce27bf53-569f-45a0-ad5a-08e8f322c717

Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>

* remove extra_tests/snippets/inspect_getsource.py (covered by test_inspect)

Agent-Logs-Url: https://github.com/RustPython/RustPython/sessions/2b64da1b-8aab-4fec-8b28-3a21d46ac2f9

Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>
2026-03-29 00:52:34 +09:00
Lee Dogeon
e7d2b57dcc Match __module__ setter behavior to CPython (#7424)
* Remove stale __firstlineno__ when updating type.__module__

* Register and use __firstlineno__ as identifier
2026-03-14 15:48:48 +09:00
Jeong, YunWon
ccd377cc47 instruction CACHE (#7251)
* Emit CACHE code units in bytecode to match CPython 3.14

- Add cache_entries() method to Instruction enum
- Emit CACHE code units after opcodes in finalize_code
- Handle NO_LOCATION (line=-1) in linetable for CACHE entries
- Account for CACHE entries in exception table generation
- Skip CACHE entries in VM execution loop (with jump detection)
- Handle CACHE in InstrumentedLine/InstrumentedInstruction/InstrumentedForIter/InstrumentedNotTaken
- Skip CACHE in monitoring instrumentation phases
- Update co_branches() for cache-adjusted offsets
- Restore _cache_format in Lib/opcode.py
- Remove expectedFailure from test_c_call, test_start_offset

* Use relative jump offsets and fix bytecode layout

- Convert jump arguments from absolute to relative offsets
  in frame.rs, monitoring.rs, and stack_analysis
- Add jump_relative_forward/backward helpers to ExecutingFrame
- Resolve pseudo jump instructions before offset fixpoint loop
- Emit NOP for break, continue, pass to match line-tracing
- Fix async for: emit EndAsyncFor with correct target, add NotTaken
- Fix comprehension if-cleanup to use separate block
- Fix super() source range for multi-line calls
- Fix NOP removal to preserve line-marker NOPs
- Fix InstrumentedLine cache skipping after re-dispatch
- Match InstrumentedResume/YieldValue in yield_from_target
- Remove CALL_FUNCTION_EX cache entry from opcode.py
- Remove resolved expectedFailure markers

* Align CPython 3.14 LOAD_GLOBAL null-bit and RERAISE semantics

* Remove redundant CPython-referencing comments

Clean up comments that unnecessarily mention CPython per project
convention. Replace with concise descriptions of the behavior itself.
2026-03-01 14:51:54 +09:00
Jeong, YunWon
6950baf687 more algorithm-independent GC infra (#7194)
* mark poluting tests

* GC-infra independent to EBR

* trashcan

* add overflow guard to inc(), #[must_use] on dec()/safe_inc(), trashcan debug_assert, weakref generic re-check
2026-02-22 21:31:42 +09:00
Lee Dogeon
3d33bea285 Remove expectedFailure from test_types_coroutine_wrapper_state
The types.py upgrade added gi_suspended to _GeneratorWrapper,
fixing this test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 18:39:56 +09:00
CPython Developers
1f290dccfe Update hashlib from v3.14.3 2026-02-14 21:40:04 +09:00
CPython Developers
b6d08fe371 Update test_unpack_ex from v3.14.2 2026-02-12 01:01:35 +09:00
Jeong, YunWon
ad6e965ad3 apply tests 2026-02-11 16:50:23 +09:00
Shahar Naveh
3d283bb91f Update some libs&tests to 3.14.3 (#7006)
* Update some libs&tests to 3.14.3

* Update argparse from 3.14.3

* Update inspect

* Update `configparser.py` from 3.14.3
2026-02-07 19:09:42 +09:00
Jeong, YunWon
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
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
111ced08e4 Fix member_descriptor to match CPython behavior (#6915)
descriptor.rs:
- Add __objclass__, __name__ (pymember) and __reduce__ (pymethod)
- Add type check (descr_check) in descr_get; simplify None branch
- Remove incorrect BASETYPE flag
- Add MemberKind::Object (_Py_T_OBJECT = 6)
- Prevent Bool slot deletion (TypeError)
- Raise AttributeError on ObjectEx deletion when already None

pyclass.rs (derive-impl):
- Remove duplicate MemberKind enum; use MemberKindStr (Option<String>)
- Simplify MemberNursery map key from (String, MemberKind) to String
- Support #[pymember(type="object")] for _Py_T_OBJECT semantics

test_inspect.py:
- Remove expectedFailure from test_getdoc (now passing)
2026-02-01 09:41:38 +09: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
Lee Dogeon
3bcd071e4d Bump collections to 3.14.2 (#6770)
* Bump collections to 3.14.2

* Unmark resolved tests
2026-01-20 23:58:43 +09:00
Jeong, YunWon
e01f26c1f6 Update inspect from v3.14.2 (#6815)
* Update inspect from v3.14.2

* temp asyncio.event._set_event_loop_policy

* mark inspect tests

---------

Co-authored-by: CPython Developers <>
2026-01-20 21:34:34 +09:00
Jeong, YunWon
1dceb7533d mark failing tests on test_types 2026-01-20 10:59:47 +09:00
Shahar Naveh
a400386774 Remove _dis module (#6690)
* Remove `_dis` module

* Adjust CodeFlag
2026-01-10 22:11:53 +09:00
Jeong, YunWon
a445a22868 fix compiler (#6615) 2026-01-01 16:55:39 +09:00
Jeong, YunWon
527111bc98 PyWrapperDescrObject and rewrite toggle_slot (#6536)
* SlotFunc

* slotdef

* unify slots

* remove unsed slots
2025-12-28 11:44:36 +09:00
Jeong, YunWon
aae6bf566f Add tp_str (#6495)
* clean up hash

* __str__ slot wrapper
2025-12-25 11:00:53 +09:00
Jeong, YunWon
3d7e521acd introduce slot_wrapper (#4884) 2025-12-24 17:29:47 +09:00
Jeong, YunWon
9bbfdf5067 mark expectedFailure 2025-12-12 21:44:00 +09:00
Jeong, YunWon
ef6c6ad117 patch test_inspect 2025-12-12 21:44:00 +09:00
Jeong, YunWon
d22956ebc1 inspect from v3.13.10 2025-12-12 21:43:24 +09:00