mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +00:00
some fix
This commit is contained in:
parent
f0b3cb102e
commit
7c1174f816
@ -508,14 +508,14 @@ void py_newglobals(py_Ref out) {
|
||||
void py_newlocals(py_Ref out) {
|
||||
Frame* frame = pk_current_vm->top_frame;
|
||||
if(!frame) {
|
||||
py_newglobals(out);
|
||||
py_newdict(out);
|
||||
return;
|
||||
}
|
||||
if(frame->is_locals_special) {
|
||||
switch(frame->locals->type) {
|
||||
case tp_locals: frame = frame->locals->_ptr; break;
|
||||
case tp_dict: *out = *frame->locals; return;
|
||||
case tp_nil: py_newglobals(out); return;
|
||||
case tp_nil: py_newdict(out); return;
|
||||
default: c11__unreachable();
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ my_locals = {"b": 2}
|
||||
# With user-defined locals:
|
||||
exec("""
|
||||
import sys
|
||||
assert locals() != globals()
|
||||
assert "sys" in locals()
|
||||
assert "sys" not in globals()
|
||||
assert "a" not in locals()
|
||||
@ -18,7 +17,6 @@ assert "b" not in globals()
|
||||
# print(b)
|
||||
assert (b == 2), b
|
||||
def main():
|
||||
assert locals() != globals()
|
||||
assert "sys" not in locals() # not the same `locals()` as the outer scope
|
||||
assert "sys" not in globals() # and `sys` isn't in `globals()`, same as before
|
||||
assert "b" not in locals() # again, not the same `locals()` as the outer scope
|
||||
@ -32,7 +30,7 @@ assert "sys" not in globals()
|
||||
# With default locals:
|
||||
exec("""
|
||||
import sys
|
||||
assert "sys" in locals()
|
||||
assert locals() == {}
|
||||
assert "sys" in globals()
|
||||
def main():
|
||||
assert "sys" not in locals() # not the same locals as the outer scope
|
||||
|
Loading…
x
Reference in New Issue
Block a user