diff --git a/mypyc/primitives/dict_ops.py b/mypyc/primitives/dict_ops.py index 0b9fca6ea2c0..e40eb644c1e3 100644 --- a/mypyc/primitives/dict_ops.py +++ b/mypyc/primitives/dict_ops.py @@ -148,7 +148,7 @@ arg_types=[dict_rprimitive], return_type=void_rtype, c_function_name='CPyDict_Clear', - error_kind=ERR_NEVER) + error_kind=ERR_MAGIC) # list(dict.keys()) dict_keys_op = custom_op( diff --git a/mypyc/test-data/run-dicts.test b/mypyc/test-data/run-dicts.test index 66c8eb0e7cb3..651f72db2957 100644 --- a/mypyc/test-data/run-dicts.test +++ b/mypyc/test-data/run-dicts.test @@ -92,6 +92,7 @@ assert get_content(od) == ([3, 1], [4, 2], [(3, 4), (1, 2)]) assert get_content_set({1: 2}) == ({1}, {2}, {(1, 2)}) assert get_content_set(od) == ({1, 3}, {2, 4}, {(1, 2), (3, 4)}) +from collections import defaultdict d = {'a': 1, 'b': 2} d.clear() assert d == {}