mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
inspect: Fix getcallargs() to raise correct TypeError
... for missing keyword-only arguments. Patch by Jeremiah Lowin. Closes #20816.
This commit is contained in:
parent
374375dd26
commit
875df20e8a
3 changed files with 12 additions and 1 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue