From 47685180f02254a9d2dfd2eb9dafc24888daeb33 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Tue, 29 Mar 2022 13:15:15 -0500 Subject: [PATCH] tests/basics/fun_callstardblstar: Add coverage test. This fixes code coverage for the case where a *arg without __len__ is unpacked and uses exactly the amount of memory that was allocated for kw args. This triggers the code branch where the memory for the kw args gets reallocated since it was used already by the *arg unpacking. Signed-off-by: David Lechner --- tests/basics/fun_callstardblstar.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/basics/fun_callstardblstar.py b/tests/basics/fun_callstardblstar.py index aceb04a843..7db458b561 100644 --- a/tests/basics/fun_callstardblstar.py +++ b/tests/basics/fun_callstardblstar.py @@ -25,3 +25,12 @@ try: eval("a.f(**{'a': 1}, *(2, 3, 4))") except SyntaxError: print("SyntaxError") + + +# coverage test for arg allocation corner case + +def f2(*args, **kwargs): + print(len(args), len(kwargs)) + + +f2(*iter(range(4)), **{'a': 1})