File tree Expand file tree Collapse file tree 2 files changed +3
-9
lines changed Expand file tree Collapse file tree 2 files changed +3
-9
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,11 @@ def b():
15
15
16
16
def x ():
17
17
def y ():
18
+ global a
18
19
nonlocal b
20
+ assert a == 4 , a
19
21
b = 3
22
+ a = "no!" # a here shouldn't be seen by the global above.
20
23
b = 2
21
24
y ()
22
25
return b
Original file line number Diff line number Diff line change @@ -179,15 +179,6 @@ impl NameProtocol for Scope {
179
179
#[ cfg_attr( feature = "flame-it" , flame( "Scope" ) ) ]
180
180
/// Load a global name.
181
181
fn load_global ( & self , vm : & VirtualMachine , name : & str ) -> Option < PyObjectRef > {
182
- // First, take a look in the outmost local scope (the scope at top level)
183
- let last_local_dict = self . locals . iter ( ) . last ( ) ;
184
- if let Some ( local_dict) = last_local_dict {
185
- if let Some ( value) = local_dict. get_item_option ( name, vm) . unwrap ( ) {
186
- return Some ( value) ;
187
- }
188
- }
189
-
190
- // Now, take a look at the globals or builtins.
191
182
if let Some ( value) = self . globals . get_item_option ( name, vm) . unwrap ( ) {
192
183
Some ( value)
193
184
} else {
You can’t perform that action at this time.
0 commit comments