From b1d060bf8b017d2a6cf6a0191b1451aeb27a5c03 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Thu, 27 Mar 2014 18:23:03 -0400 Subject: inspect: Fix getcallargs() to raise correct TypeError ... for missing keyword-only arguments. Patch by Jeremiah Lowin. Closes #20816. --- Lib/test/test_inspect.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Lib/test') diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index 5c6ae394d5..20f7217d44 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -1206,6 +1206,14 @@ class TestGetcallargsFunctions(unittest.TestCase): self.assertEqualException(f3, '1, 2') self.assertEqualException(f3, '1, 2, a=1, b=2') + # issue #20816: getcallargs() fails to iterate over non-existent + # kwonlydefaults and raises a wrong TypeError + def f5(*, a): pass + with self.assertRaisesRegex(TypeError, + 'missing 1 required keyword-only'): + inspect.getcallargs(f5) + + class TestGetcallargsMethods(TestGetcallargsFunctions): def setUp(self): -- cgit v1.2.1