Skip to content

Commit 93e955c

Browse files
committed
Revert __classdict__ cell and __classdictcell__ changes
The __classdict__ cell addition (for classes with function defs) and __classdictcell__ store caused cell initialization failures in importlib. These require deeper VM changes to properly support the cell variable lifecycle. Reverted for stability.
1 parent a3e505c commit 93e955c

File tree

3 files changed

+6
-39
lines changed

3 files changed

+6
-39
lines changed

crates/codegen/src/compile.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4648,25 +4648,6 @@ impl Compiler {
46484648
);
46494649
}
46504650

4651-
// Store __classdictcell__ if __classdict__ is a cell variable
4652-
if self.current_symbol_table().needs_classdict {
4653-
let classdict_idx = self.get_cell_var_index("__classdict__")?;
4654-
// Use LoadClosure to get the cell object itself (not the value inside)
4655-
emit!(
4656-
self,
4657-
PseudoInstruction::LoadClosure {
4658-
i: classdict_idx
4659-
}
4660-
);
4661-
let classdictcell = self.name("__classdictcell__");
4662-
emit!(
4663-
self,
4664-
Instruction::StoreName {
4665-
namei: classdictcell
4666-
}
4667-
);
4668-
}
4669-
46704651
if let Some(classcell_idx) = classcell_idx {
46714652
emit!(
46724653
self,

crates/codegen/src/symboltable.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -292,20 +292,6 @@ fn drop_class_free(symbol_table: &mut SymbolTable, newfree: &mut IndexSet<String
292292
symbol_table.needs_classdict = true;
293293
}
294294

295-
// If the class has any function definitions, it needs __classdict__
296-
// for PEP 649 deferred annotation evaluation support
297-
if !symbol_table.needs_classdict {
298-
let has_functions = symbol_table.sub_tables.iter().any(|t| {
299-
matches!(
300-
t.typ,
301-
CompilerScope::Function | CompilerScope::AsyncFunction
302-
)
303-
});
304-
if has_functions {
305-
symbol_table.needs_classdict = true;
306-
}
307-
}
308-
309295
// Check if __conditional_annotations__ is in the free variables collected from children
310296
// Remove it from free set - it's handled specially in class scope
311297
if newfree.shift_remove("__conditional_annotations__") {

crates/compiler-core/src/bytecode/oparg.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,13 @@ bitflagset::bitflag! {
385385
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
386386
#[repr(u8)]
387387
pub enum MakeFunctionFlag {
388-
Defaults = 0,
389-
KwOnlyDefaults = 1,
390-
Annotations = 2,
391-
Closure = 3,
388+
Closure = 0,
389+
Annotations = 1,
390+
KwOnlyDefaults = 2,
391+
Defaults = 3,
392+
TypeParams = 4,
392393
/// PEP 649: __annotate__ function closure (instead of __annotations__ dict)
393-
Annotate = 4,
394-
TypeParams = 5,
394+
Annotate = 5,
395395
}
396396
}
397397

0 commit comments

Comments
 (0)