Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Lib/test/test_listcomps.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,15 @@ def test_multiple_comprehension_name_reuse(self):
self._check_in_scopes(code, {"x": 2, "y": [3]}, ns={"x": 3}, scopes=["class"])
self._check_in_scopes(code, {"x": 2, "y": [2]}, ns={"x": 3}, scopes=["function", "module"])

def test_name_collision_locals(self):
code = """
x = 1
[x for x in [0]]
from abc import *
exec("b = 2")
"""
self._check_in_scopes(code, {"b": 2, "x": 1}, scopes=["module"])

def test_exception_locations(self):
# The location of an exception raised from __init__ or
# __next__ should should be the iterator expression
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed an issue where ``_PyFrame_LocalsToFast`` tries to write module level
values to hidden fasts.
3 changes: 3 additions & 0 deletions Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,9 @@ _PyFrame_LocalsToFast(_PyInterpreterFrame *frame, int clear)
if (kind & CO_FAST_FREE && !(co->co_flags & CO_OPTIMIZED)) {
continue;
}
if (kind & CO_FAST_HIDDEN) {
continue;
}
PyObject *name = PyTuple_GET_ITEM(co->co_localsplusnames, i);
PyObject *value = PyObject_GetItem(locals, name);
/* We only care about NULLs if clear is true. */
Expand Down
Loading