File tree Expand file tree Collapse file tree 3 files changed +5
-4
lines changed
Expand file tree Collapse file tree 3 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -128,8 +128,6 @@ def test_nonlocal(self):
128128 expected = ("some_var" ,)
129129 self .assertEqual (self .other_internal .get_nonlocals (), expected )
130130
131- # TODO: RUSTPYTHON
132- @unittest .expectedFailure
133131 def test_local (self ):
134132 self .assertTrue (self .spam .lookup ("x" ).is_local ())
135133 self .assertFalse (self .spam .lookup ("bar" ).is_local ())
Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ impl Symbol {
150150 }
151151
152152 pub fn is_local ( & self ) -> bool {
153- self . scope == SymbolScope :: Local
153+ matches ! ( self . scope, SymbolScope :: Local | SymbolScope :: Cell )
154154 }
155155
156156 pub fn is_bound ( & self ) -> bool {
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ mod symtable {
8989 . filter ( |table| table. name == name)
9090 . cloned ( )
9191 . collect ( ) ,
92+ is_top_scope : self . symtable . name == "top" ,
9293 }
9394 . into_ref ( vm) )
9495 } else {
@@ -123,6 +124,7 @@ mod symtable {
123124 . filter ( |& table| table. name == s. name )
124125 . cloned ( )
125126 . collect ( ) ,
127+ is_top_scope : self . symtable . name == "top" ,
126128 } )
127129 . into_ref ( vm)
128130 . into ( )
@@ -154,6 +156,7 @@ mod symtable {
154156 struct PySymbol {
155157 symbol : Symbol ,
156158 namespaces : Vec < SymbolTable > ,
159+ is_top_scope : bool ,
157160 }
158161
159162 impl fmt:: Debug for PySymbol {
@@ -176,7 +179,7 @@ mod symtable {
176179
177180 #[ pymethod]
178181 fn is_local ( & self ) -> bool {
179- self . symbol . is_local ( )
182+ self . symbol . is_local ( ) || ( self . is_top_scope && self . symbol . is_bound ( ) )
180183 }
181184
182185 #[ pymethod]
You can’t perform that action at this time.
0 commit comments