no confusions in executions for dict assignments, fixes #83

This commit is contained in:
David Halter
2012-12-19 21:23:50 +01:00
parent bb31d3de3f
commit ca21f76128
3 changed files with 8 additions and 3 deletions

View File

@@ -1066,13 +1066,17 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False,
if is_execution(a):
return True
elif a.isinstance(parsing.Call):
if a.name == name and a.execution:
# Compare start_pos, because names may be different
# because of executions.
if a.name.start_pos == name.start_pos \
and a.execution:
return True
return False
is_exe = False
for op, assignee in par.assignment_details:
is_exe |= is_execution(assignee)
if is_exe:
# filter array[3] = ...
# TODO check executions for dict contents

View File

@@ -766,8 +766,7 @@ class Statement(Simple):
self._assignment_details.append((tok, top))
# All these calls wouldn't be important if nonlocal would
# exist. -> Initialize the first item again.
result = Array(start_pos, Array.NOARRAY, self)
top = result
top = result = Array(start_pos, Array.NOARRAY, self)
level = 0
close_brackets = False
is_chain = False
@@ -776,6 +775,7 @@ class Statement(Simple):
next(tok_iter, None)
continue
# here starts the statement creation madness!
brackets = {'(': Array.TUPLE, '[': Array.LIST, '{': Array.SET}
is_call = lambda: type(result) == Call
is_call_or_close = lambda: is_call() or close_brackets

View File

@@ -163,6 +163,7 @@ dic2[r'asdf']
dic2['just_something']
def f():
""" github #83 """
r = {}
r['status'] = (200, 'ok')
return r