Instruction 3.14#6805
Conversation
📝 WalkthroughWalkthroughAligns RustPython's bytecode instruction set and opcodes with CPython 3.14, replacing CPython 3.13 definitions, introducing new opcodes (BinarySlice, BuildTemplate, GetLen, etc.), removing deprecated instruction variants (BuildListFromTuples, BuildMapForCall, etc.), and updating the pyc magic number. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/compiler-core/src/bytecode/instruction.rs (1)
416-463: RustPython cannot deserialize CPython 3.14 bytecode using opcodes 121‑127 or 226‑233.CPython 3.14 assigns opcodes throughout the entire range 0–255. Specifically, values 121–127 are assigned to
STORE_FAST_LOAD_FASTthroughFAST_FUNCTION, and values 226–233 are assigned toBUILD_MAP__RETURN_VALUEthroughMATCH_CLASS__RETURN_VALUE. The currentTryFrom<u8>implementation rejects these ranges, causing valid CPython 3.14 bytecode to fail deserialization. These gaps must be filled with the corresponding CPython 3.14 opcodes to maintain compatibility.
🤖 Fix all issues with AI agents
In `@crates/compiler-core/src/bytecode/instruction.rs`:
- Around line 17-199: The GetAwaitable opcode in the Instruction enum is missing
the required oparg ("where") per CPython 3.14; update the
Instruction::GetAwaitable variant to include an oparg field (e.g. GetAwaitable {
oparg: Arg<u32> } or a small enum type Arg<GetAwaitableWhere>) so
decoding/encoding and semantics can read 0/1/2 contexts correctly; search for
Instruction::GetAwaitable and adjust any places that construct, pattern-match,
encode/decode, or format Instruction to handle the new oparg field (and add a
small GetAwaitableWhere type if you prefer typed values instead of raw u32).
In `@crates/vm/src/version.rs`:
- Around line 131-132: The constant PYC_MAGIC_NUMBER is set incorrectly to 2996;
update the value of pub const PYC_MAGIC_NUMBER in version.rs to 3627 so it
matches CPython 3.14's magic number (as defined in CPython's
pycore_magic_number) to ensure .pyc files from CPython 3.14 are read correctly.
🧹 Nitpick comments (1)
crates/compiler-core/src/bytecode/instruction.rs (1)
872-1011: Add disassembly formatting for newly added opcodes to avoid placeholder output.Several new variants (e.g.,
LoadCommonConstant,LoadSmallInt,LoadSpecial,LoadFastBorrow,BinarySlice,StoreSlice) currently fall through toRUSTPYTHON_PLACEHOLDER, makingdisoutput harder to read. Consider adding explicit formatters.♻️ Suggested disassembly cases
@@ - Self::BinarySubscr => w!(BINARY_SUBSCR), + Self::BinarySubscr => w!(BINARY_SUBSCR), + Self::BinarySlice => w!(BINARY_SLICE), @@ - Self::LoadBuildClass => w!(LOAD_BUILD_CLASS), - Self::LoadFromDictOrDeref(i) => w!(LOAD_FROM_DICT_OR_DEREF, cell_name = i), - Self::LoadConst { idx } => fmt_const("LOAD_CONST", arg, f, idx), + Self::LoadBuildClass => w!(LOAD_BUILD_CLASS), + Self::LoadCommonConstant { idx } => w!(LOAD_COMMON_CONSTANT, idx), + Self::LoadSmallInt { idx } => w!(LOAD_SMALL_INT, idx), + Self::LoadSpecial { arg } => w!(LOAD_SPECIAL, arg), + Self::LoadFromDictOrDeref(i) => w!(LOAD_FROM_DICT_OR_DEREF, cell_name = i), + Self::LoadConst { idx } => fmt_const("LOAD_CONST", arg, f, idx), Self::LoadDeref(idx) => w!(LOAD_DEREF, cell_name = idx), Self::LoadFast(idx) => w!(LOAD_FAST, varname = idx), Self::LoadFastAndClear(idx) => w!(LOAD_FAST_AND_CLEAR, varname = idx), + Self::LoadFastBorrow(idx) => w!(LOAD_FAST_BORROW, varname = idx), @@ - Self::StoreSubscr => w!(STORE_SUBSCR), + Self::StoreSubscr => w!(STORE_SUBSCR), + Self::StoreSlice => w!(STORE_SLICE),
Sorry, something went wrong.
97167ab
into
RustPython:main
Jan 19, 2026
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.