Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
marshal v5
  • Loading branch information
youknowone committed Jan 17, 2026
commit 1af3c027b49a27036c37497892c0e49cf0d48b26
8 changes: 7 additions & 1 deletion crates/codegen/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4186,6 +4186,10 @@ impl Compiler {
firstlineno: u32,
) -> CompileResult<CodeObject> {
// 1. Enter class scope
// Reset conditional-annotation index for class scope (restore after)
let saved_conditional_index = self.next_conditional_annotation_index;
self.next_conditional_annotation_index = 0;

let key = self.symbol_table_stack.len();
self.push_symbol_table()?;
self.enter_scope(name, CompilerScope::Class, key, firstlineno)?;
Expand Down Expand Up @@ -4290,7 +4294,9 @@ impl Compiler {
self.emit_return_value();

// Exit scope and return the code object
Ok(self.exit_scope())
let code = self.exit_scope();
self.next_conditional_annotation_index = saved_conditional_index;
Ok(code)
}

fn compile_class_def(
Expand Down
10 changes: 9 additions & 1 deletion crates/compiler-core/src/marshal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use malachite_bigint::{BigInt, Sign};
use num_complex::Complex64;
use rustpython_wtf8::Wtf8;

pub const FORMAT_VERSION: u32 = 4;
pub const FORMAT_VERSION: u32 = 5;

#[derive(Debug)]
pub enum MarshalError {
Expand Down Expand Up @@ -65,6 +65,7 @@ enum Type {
// Unknown = b'?',
Set = b'<',
FrozenSet = b'>',
Slice = b':', // Added in version 5
Ascii = b'a',
// AsciiInterned = b'A',
// SmallTuple = b')',
Expand Down Expand Up @@ -101,6 +102,7 @@ impl TryFrom<u8> for Type {
// b'?' => Unknown,
b'<' => Set,
b'>' => FrozenSet,
b':' => Slice,
b'a' => Ascii,
// b'A' => AsciiInterned,
// b')' => SmallTuple,
Expand Down Expand Up @@ -466,6 +468,12 @@ pub fn deserialize_value<R: Read, Bag: MarshalBag>(rdr: &mut R, bag: Bag) -> Res
bag.make_bytes(value)
}
Type::Code => bag.make_code(deserialize_code(rdr, bag.constant_bag())?),
Type::Slice => {
// Slice constants are not yet supported in RustPython
// This would require adding a Slice variant to ConstantData enum
// For now, return an error if we encounter a slice in marshal data
return Err(MarshalError::BadType);
}
};
Ok(value)
}
Expand Down