@@ -3,9 +3,10 @@ pub(crate) use _symtable::module_def;
33#[ pymodule]
44mod _symtable {
55 use crate :: {
6- PyObjectRef , PyPayload , PyRef , PyResult , VirtualMachine ,
6+ Py , PyObjectRef , PyPayload , PyRef , PyResult , VirtualMachine ,
77 builtins:: { PyDictRef , PyStrRef } ,
88 compiler,
9+ types:: Representable ,
910 } ;
1011 use alloc:: fmt;
1112 use rustpython_codegen:: symboltable:: {
@@ -132,7 +133,7 @@ mod _symtable {
132133 }
133134
134135 #[ pyattr]
135- #[ pyclass( name = "SymbolTable " ) ]
136+ #[ pyclass( name = "symtable entry " ) ]
136137 #[ derive( PyPayload ) ]
137138 struct PySymbolTable {
138139 symtable : SymbolTable ,
@@ -144,7 +145,7 @@ mod _symtable {
144145 }
145146 }
146147
147- #[ pyclass]
148+ #[ pyclass( with ( Representable ) ) ]
148149 impl PySymbolTable {
149150 #[ pygetset]
150151 fn name ( & self ) -> String {
@@ -210,6 +211,19 @@ mod _symtable {
210211 }
211212 }
212213
214+ impl Representable for PySymbolTable {
215+ #[ inline]
216+ fn repr_str ( zelf : & Py < Self > , vm : & VirtualMachine ) -> PyResult < String > {
217+ Ok ( format ! (
218+ "<{} {}({}), line {}>" ,
219+ Self :: class( & vm. ctx) . name( ) ,
220+ zelf. symtable. name,
221+ zelf. id( ) ,
222+ zelf. symtable. line_number
223+ ) )
224+ }
225+ }
226+
213227 #[ pyattr]
214228 #[ pyclass( name = "Symbol" ) ]
215229 #[ derive( PyPayload ) ]
0 commit comments