diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2014-03-27 22:23:03 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2014-03-27 22:23:03 (GMT) |
commit | 875df20e8a2a9bad07a42f0175be019d915e0845 (patch) | |
tree | e1e6b9db6c30cf52d99e36b4f6becaba4ff37315 /Lib/test | |
parent | 374375dd26118ccb7027f66d66ab9e80c82f4103 (diff) | |
download | cpython-875df20e8a2a9bad07a42f0175be019d915e0845.zip cpython-875df20e8a2a9bad07a42f0175be019d915e0845.tar.gz cpython-875df20e8a2a9bad07a42f0175be019d915e0845.tar.bz2 |
inspect: Fix getcallargs() to raise correct TypeError
... for missing keyword-only arguments. Patch by Jeremiah Lowin.
Closes #20816.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_inspect.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index 95b8877..b943530 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -1208,6 +1208,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): |