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 (#8309) · RustPython/RustPython@0bc109d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • crates/vm/src/stdlib
    • _symtable.rs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎crates/vm/src/stdlib/_symtable.rs‎

Copy file name to clipboardExpand all lines: crates/vm/src/stdlib/_symtable.rs
+1-114Lines changed: 1 addition & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ mod _symtable {
99
types::Representable,
1010
};
1111
use alloc::fmt;
12-
use rustpython_codegen::symboltable::{
13-
CompilerScope, Symbol, SymbolFlags, SymbolScope, SymbolTable,
14-
};
12+
use rustpython_codegen::symboltable::{CompilerScope, SymbolFlags, SymbolScope, SymbolTable};
1513

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

186-
#[pygetset]
187-
fn identifiers(&self, vm: &VirtualMachine) -> Vec<PyObjectRef> {
188-
self.symtable
189-
.symbols
190-
.keys()
191-
.map(|s| vm.ctx.new_str(s.as_str()).into())
192-
.collect()
193-
}
194-
195184
#[pygetset]
196185
fn symbols(&self, vm: &VirtualMachine) -> PyDictRef {
197186
let dict = vm.ctx.new_dict();
@@ -220,106 +209,4 @@ mod _symtable {
220209
))
221210
}
222211
}
223-
224-
#[pyattr]
225-
#[pyclass(name = "Symbol")]
226-
#[derive(PyPayload)]
227-
struct PySymbol {
228-
symbol: Symbol,
229-
namespaces: Vec<SymbolTable>,
230-
is_top_scope: bool,
231-
}
232-
233-
impl fmt::Debug for PySymbol {
234-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
235-
write!(f, "Symbol()")
236-
}
237-
}
238-
239-
#[pyclass]
240-
impl PySymbol {
241-
#[pymethod]
242-
fn get_name(&self) -> String {
243-
self.symbol.name.clone()
244-
}
245-
246-
#[pymethod]
247-
const fn is_global(&self) -> bool {
248-
self.symbol.is_global() || (self.is_top_scope && self.symbol.is_bound())
249-
}
250-
251-
#[pymethod]
252-
const fn is_declared_global(&self) -> bool {
253-
matches!(self.symbol.scope, SymbolScope::GlobalExplicit)
254-
}
255-
256-
#[pymethod]
257-
const fn is_local(&self) -> bool {
258-
self.symbol.is_local() || (self.is_top_scope && self.symbol.is_bound())
259-
}
260-
261-
#[pymethod]
262-
const fn is_imported(&self) -> bool {
263-
self.symbol.flags.contains(SymbolFlags::DEF_IMPORT)
264-
}
265-
266-
#[pymethod]
267-
const fn is_nested(&self) -> bool {
268-
// TODO
269-
false
270-
}
271-
272-
#[pymethod]
273-
const fn is_nonlocal(&self) -> bool {
274-
self.symbol.flags.contains(SymbolFlags::DEF_NONLOCAL)
275-
}
276-
277-
#[pymethod]
278-
const fn is_referenced(&self) -> bool {
279-
self.symbol.flags.contains(SymbolFlags::USE)
280-
}
281-
282-
#[pymethod]
283-
const fn is_assigned(&self) -> bool {
284-
self.symbol.flags.contains(SymbolFlags::DEF_LOCAL)
285-
}
286-
287-
#[pymethod]
288-
const fn is_parameter(&self) -> bool {
289-
self.symbol.flags.contains(SymbolFlags::DEF_PARAM)
290-
}
291-
292-
#[pymethod]
293-
const fn is_free(&self) -> bool {
294-
matches!(self.symbol.scope, SymbolScope::Free)
295-
}
296-
297-
#[pymethod]
298-
const fn is_namespace(&self) -> bool {
299-
!self.namespaces.is_empty()
300-
}
301-
302-
#[pymethod]
303-
const fn is_annotated(&self) -> bool {
304-
self.symbol.flags.contains(SymbolFlags::DEF_ANNOT)
305-
}
306-
307-
#[pymethod]
308-
fn get_namespaces(&self, vm: &VirtualMachine) -> Vec<PyObjectRef> {
309-
self.namespaces
310-
.iter()
311-
.map(|table| to_py_symbol_table(table.clone()).into_pyobject(vm))
312-
.collect()
313-
}
314-
315-
#[pymethod]
316-
fn get_namespace(&self, vm: &VirtualMachine) -> PyResult {
317-
if self.namespaces.len() != 1 {
318-
return Err(vm.new_value_error("namespace is bound to multiple namespaces"));
319-
}
320-
Ok(to_py_symbol_table(self.namespaces.first().unwrap().clone())
321-
.into_ref(&vm.ctx)
322-
.into())
323-
}
324-
}
325212
}

0 commit comments

Comments
0 (0)
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.