diff options
| author | Yury Selivanov <yselivanov@sprymix.com> | 2014-03-27 22:42:52 (GMT) |
|---|---|---|
| committer | Yury Selivanov <yselivanov@sprymix.com> | 2014-03-27 22:42:52 (GMT) |
| commit | dccfa13cdbdb618da3f45f1023c6626be6abb056 (patch) | |
| tree | d71574745b39ffd6efaad082db7c3ff8c5a619b5 | |
| parent | 875df20e8a2a9bad07a42f0175be019d915e0845 (diff) | |
| download | cpython-dccfa13cdbdb618da3f45f1023c6626be6abb056.zip cpython-dccfa13cdbdb618da3f45f1023c6626be6abb056.tar.gz cpython-dccfa13cdbdb618da3f45f1023c6626be6abb056.tar.bz2 | |
inspect: Fix getcallargs() to fail correctly if more than 3 args are missing.
Patch by Jeremiah Lowin. Closes #20817.
| -rw-r--r-- | Lib/inspect.py | 2 | ||||
| -rw-r--r-- | Lib/test/test_inspect.py | 6 | ||||
| -rw-r--r-- | Misc/NEWS | 3 |
3 files changed, 10 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index fdb5e2a..bb31098 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -1127,7 +1127,7 @@ def _missing_arguments(f_name, argnames, pos, values): elif missing == 2: s = "{} and {}".format(*names) else: - tail = ", {} and {}".format(names[-2:]) + tail = ", {} and {}".format(*names[-2:]) del names[-2:] s = ", ".join(names) + tail raise TypeError("%s() missing %i required %s argument%s: %s" % diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index b943530..881ca95 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -1216,6 +1216,12 @@ class TestGetcallargsFunctions(unittest.TestCase): inspect.getcallargs(f5) + # issue20817: + def f6(a, b, c): + pass + with self.assertRaisesRegex(TypeError, "'a', 'b' and 'c'"): + inspect.getcallargs(f6) + class TestGetcallargsMethods(TestGetcallargsFunctions): def setUp(self): @@ -116,6 +116,9 @@ Library - Issue #20816: Fix inspect.getcallargs() to raise correct TypeError for missing keyword-only arguments. Patch by Jeremiah Lowin. +- Issue #20817: Fix inspect.getcallargs() to fail correctly if more + than 3 arguments are missing. Patch by Jeremiah Lowin. + Documentation ------------- |
