Visitar URL original
gc: add CollectResult, stats fields, get_referrers, and fix count reset by youknowone · Pull Request #7354 · RustPython/RustPython · GitHub
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
Prev Previous commit
Disable comp_inlined in symbol table to match compiler
The compiler does not yet implement PEP 709 inlined comprehensions
(is_inlined_comprehension_context always returns false), but the
symbol table was marking comprehensions as inlined. This mismatch
could cause comprehension-local symbols to be merged into the parent
scope while the compiler still looks them up in a separate scope.
  • Loading branch information
youknowone committed Mar 10, 2026
commit d62481f552d5eccd1cf60ccdfb5b843541e42eab
1 change: 0 additions & 1 deletion Lib/test/test_symtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,6 @@ def get_identifiers_recursive(self, st, res):
for ch in st.get_children():
self.get_identifiers_recursive(ch, res)

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: 2 != 1
def test_loopvar_in_only_one_scope(self):
# ensure that the loop variable appears only once in the symtable
comps = [
Expand Down
21 changes: 7 additions & 14 deletions crates/codegen/src/symboltable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2037,20 +2037,13 @@ impl SymbolTableBuilder {
self.line_index_start(range),
);

// Mark non-generator comprehensions as inlined (PEP 709)
// inline_comp = entry->ste_comprehension && !entry->ste_generator && !ste->ste_can_see_class_scope
// We check is_generator and can_see_class_scope of parent
let parent_can_see_class = self
.tables
.get(self.tables.len().saturating_sub(2))
.map(|t| t.can_see_class_scope)
.unwrap_or(false);
if !is_generator
&& !parent_can_see_class
&& let Some(table) = self.tables.last_mut()
{
table.comp_inlined = true;
}
// PEP 709: inlined comprehensions are not yet implemented in the
// compiler (is_inlined_comprehension_context always returns false),
// so do NOT mark comp_inlined here. Setting it would cause the
// symbol-table analyzer to merge comprehension-local symbols into
// the parent scope, while the compiler still emits a separate code
// object — leading to the merged symbols being missing from the
// comprehension's own symbol table lookup.

// Register the passed argument to the generator function as the name ".0"
self.register_name(".0", SymbolUsage::Parameter, range)?;
Expand Down
Loading