diff --git a/mypyc/primitives/dict_ops.py b/mypyc/primitives/dict_ops.py index 9f477d0b7b90..ce7b9bb8d70e 100644 --- a/mypyc/primitives/dict_ops.py +++ b/mypyc/primitives/dict_ops.py @@ -113,7 +113,7 @@ # Operation used for **value in dict displays. # This is mostly like dict.update(obj), but has customized error handling. dict_update_in_display_op = custom_op( - arg_types=[dict_rprimitive, dict_rprimitive], + arg_types=[dict_rprimitive, object_rprimitive], return_type=c_int_rprimitive, c_function_name="CPyDict_UpdateInDisplay", error_kind=ERR_NEG_INT, diff --git a/mypyc/test-data/run-misc.test b/mypyc/test-data/run-misc.test index 267a3441808f..33f23ea3e943 100644 --- a/mypyc/test-data/run-misc.test +++ b/mypyc/test-data/run-misc.test @@ -158,7 +158,7 @@ exit! a ohno caught [case testDisplays] -from typing import List, Set, Tuple, Sequence, Dict, Any +from typing import List, Set, Tuple, Sequence, Dict, Any, Mapping def listDisplay(x: List[int], y: List[int]) -> List[int]: return [1, 2, *x, *y, 3] @@ -172,12 +172,17 @@ def tupleDisplay(x: Sequence[str], y: Sequence[str]) -> Tuple[str, ...]: def dictDisplay(x: str, y1: Dict[str, int], y2: Dict[str, int]) -> Dict[str, int]: return {x: 2, **y1, 'z': 3, **y2} +def dictDisplayUnpackMapping(obj: Mapping[str, str]) -> Dict[str, str]: + return {**obj, "env": "value"} + [file driver.py] -from native import listDisplay, setDisplay, tupleDisplay, dictDisplay +import os +from native import listDisplay, setDisplay, tupleDisplay, dictDisplay, dictDisplayUnpackMapping assert listDisplay([4], [5, 6]) == [1, 2, 4, 5, 6, 3] assert setDisplay({4}, {5}) == {1, 2, 3, 4, 5} assert tupleDisplay(['4', '5'], ['6']) == ('1', '2', '4', '5', '6', '3') assert dictDisplay('x', {'y1': 1}, {'y2': 2, 'z': 5}) == {'x': 2, 'y1': 1, 'y2': 2, 'z': 5} +assert dictDisplayUnpackMapping(os.environ) == {**os.environ, "env": "value"} [case testArbitraryLvalues] from typing import List, Dict, Any