cpython: 35302cc4fc93 (original) (raw)
Mercurial > cpython
changeset 90000:35302cc4fc93
inspect: Fix getcallargs() to fail correctly if more than 3 args are missing. Patch by Jeremiah Lowin. Closes #20817. [#20817]
Yury Selivanov yselivanov@sprymix.com | |
---|---|
date | Thu, 27 Mar 2014 18:42:52 -0400 |
parents | 3de2e729d0fb |
children | ee0034434e65 |
files | Lib/inspect.py Lib/test/test_inspect.py Misc/NEWS |
diffstat | 3 files changed, 10 insertions(+), 1 deletions(-)[+] [-] Lib/inspect.py 2 Lib/test/test_inspect.py 6 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -1127,7 +1127,7 @@ def _missing_arguments(f_name, argnames, elif missing == 2: s = "{} and {}".format(*names) else:
tail = ", {} and {}".format(names[-2:])[](#l1.7)
raise TypeError("%s() missing %i required %s argument%s: %s" %tail = ", {} and {}".format(*names[-2:])[](#l1.8) del names[-2:][](#l1.9) s = ", ".join(names) + tail[](#l1.10)
--- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -1216,6 +1216,12 @@ class TestGetcallargsFunctions(unittest. inspect.getcallargs(f5)
# issue20817:[](#l2.7)
def f6(a, b, c):[](#l2.8)
pass[](#l2.9)
with self.assertRaisesRegex(TypeError, "'a', 'b' and 'c'"):[](#l2.10)
inspect.getcallargs(f6)[](#l2.11)
+ class TestGetcallargsMethods(TestGetcallargsFunctions): def setUp(self):