Skip to content

Commit f82d532

Browse files
author
Guido van Rossum
committed
Minimal fix for crash in map_actuals_to_formals().
Fixes #1553.
1 parent b268332 commit f82d532

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

mypy/checkexpr.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,9 +1643,7 @@ def map_actuals_to_formals(caller_kinds: List[int],
16431643
argument type with the given index.
16441644
"""
16451645
ncallee = len(callee_kinds)
1646-
map = [None] * ncallee # type: List[List[int]]
1647-
for i in range(ncallee):
1648-
map[i] = []
1646+
map = [[] for i in range(ncallee)] # type: List[List[int]]
16491647
j = 0
16501648
for i, kind in enumerate(caller_kinds):
16511649
if kind == nodes.ARG_POS:
@@ -1666,7 +1664,7 @@ def map_actuals_to_formals(caller_kinds: List[int],
16661664
if callee_kinds[j] != nodes.ARG_STAR2:
16671665
map[j].append(i)
16681666
else:
1669-
raise NotImplementedError()
1667+
break
16701668
j += 1
16711669
else:
16721670
# Assume that it is an iterable (if it isn't, there will be

test-data/unit/check-kwargs.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,8 @@ f(**b) # E: Argument 1 to "f" has incompatible type **Dict[str, str]; expected "
305305
c = {0: 0}
306306
f(**c) # E: Keywords must be strings
307307
[builtins fixtures/dict.py]
308+
309+
[case testCallStar2WithStar]
310+
def f(**k): pass
311+
f(*(1, 2)) # E: Too many arguments for "f"
312+
[builtins fixtures/dict.py]

0 commit comments

Comments
 (0)