GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Remove obsolete _symtable APIs by YangSiJun528 · Pull Request #8309 · RustPython/RustPython

Remove obsolete _symtable APIs #8309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
youknowone merged 1 commit into RustPython:main from YangSiJun528:remove-obsolete-symtable-apis
Jul 18, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

Remove obsolete _symtable APIs #8309

Changes from all commits
Commits
Show all changes
1 commit
Select commit
d486b22
Remove obsolete _symtable APIs
YangSiJun528 Jul 17, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Remove obsolete _symtable APIs
stdlib/_symtable.rs previously provided the public Symbol API. When
7f1fc36 imported Lib/symtable.py, responsibility for the public Symbol
implementation moved to Python, but the native implementation remained.

Remove it along with the unused identifiers getter.

Assisted-by: Codex:gpt-5.6-sol
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@YangSiJun528
YangSiJun528 committed Jul 17, 2026
commit d486b22f79df5da61821c792f01f65a1c00d6b94

There are no files selected for viewing

115 changes: 1 addition & 114 deletions 115 crates/vm/src/stdlib/_symtable.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ mod _symtable {
types::Representable,
};
use alloc::fmt;
use rustpython_codegen::symboltable::{
CompilerScope, Symbol, SymbolFlags, SymbolScope, SymbolTable,
};
use rustpython_codegen::symboltable::{CompilerScope, SymbolFlags, SymbolScope, SymbolTable};

/// [CPython's `SCOPE_OFFSET`](https://github.com/python/cpython/blob/v3.14.6/Include/internal/pycore_symtable.h#L176)
const SCOPE_OFFSET: i32 = 12;
Expand Down Expand Up @@ -183,15 +181,6 @@ mod _symtable {
self as *const Self as *const core::ffi::c_void as usize
}

#[pygetset]
fn identifiers(&self, vm: &VirtualMachine) -> Vec<PyObjectRef> {
self.symtable
.symbols
.keys()
.map(|s| vm.ctx.new_str(s.as_str()).into())
.collect()
}

#[pygetset]
fn symbols(&self, vm: &VirtualMachine) -> PyDictRef {
let dict = vm.ctx.new_dict();
Expand Down Expand Up @@ -220,106 +209,4 @@ mod _symtable {
))
}
}

#[pyattr]
#[pyclass(name = "Symbol")]
#[derive(PyPayload)]
struct PySymbol {
symbol: Symbol,
namespaces: Vec<SymbolTable>,
is_top_scope: bool,
}

impl fmt::Debug for PySymbol {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Symbol()")
}
}

#[pyclass]
impl PySymbol {
#[pymethod]
fn get_name(&self) -> String {
self.symbol.name.clone()
}

#[pymethod]
const fn is_global(&self) -> bool {
self.symbol.is_global() || (self.is_top_scope && self.symbol.is_bound())
}

#[pymethod]
const fn is_declared_global(&self) -> bool {
matches!(self.symbol.scope, SymbolScope::GlobalExplicit)
}

#[pymethod]
const fn is_local(&self) -> bool {
self.symbol.is_local() || (self.is_top_scope && self.symbol.is_bound())
}

#[pymethod]
const fn is_imported(&self) -> bool {
self.symbol.flags.contains(SymbolFlags::DEF_IMPORT)
}

#[pymethod]
const fn is_nested(&self) -> bool {
// TODO
false
}

#[pymethod]
const fn is_nonlocal(&self) -> bool {
self.symbol.flags.contains(SymbolFlags::DEF_NONLOCAL)
}

#[pymethod]
const fn is_referenced(&self) -> bool {
self.symbol.flags.contains(SymbolFlags::USE)
}

#[pymethod]
const fn is_assigned(&self) -> bool {
self.symbol.flags.contains(SymbolFlags::DEF_LOCAL)
}

#[pymethod]
const fn is_parameter(&self) -> bool {
self.symbol.flags.contains(SymbolFlags::DEF_PARAM)
}

#[pymethod]
const fn is_free(&self) -> bool {
matches!(self.symbol.scope, SymbolScope::Free)
}

#[pymethod]
const fn is_namespace(&self) -> bool {
!self.namespaces.is_empty()
}

#[pymethod]
const fn is_annotated(&self) -> bool {
self.symbol.flags.contains(SymbolFlags::DEF_ANNOT)
}

#[pymethod]
fn get_namespaces(&self, vm: &VirtualMachine) -> Vec<PyObjectRef> {
self.namespaces
.iter()
.map(|table| to_py_symbol_table(table.clone()).into_pyobject(vm))
.collect()
}

#[pymethod]
fn get_namespace(&self, vm: &VirtualMachine) -> PyResult {
if self.namespaces.len() != 1 {
return Err(vm.new_value_error("namespace is bound to multiple namespaces"));
}
Ok(to_py_symbol_table(self.namespaces.first().unwrap().clone())
.into_ref(&vm.ctx)
.into())
}
}
}
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.