changeset: 90001:9f06cbb7962b branch: 3.4 parent: 89999:070dfca74610 user: Yury Selivanov date: Thu Mar 27 18:42:52 2014 -0400 files: Lib/inspect.py Lib/test/test_inspect.py Misc/NEWS description: inspect: Fix getcallargs() to fail correctly if more than 3 args are missing. Patch by Jeremiah Lowin. Closes #20817. diff -r 070dfca74610 -r 9f06cbb7962b Lib/inspect.py --- a/Lib/inspect.py Thu Mar 27 18:23:03 2014 -0400 +++ b/Lib/inspect.py Thu Mar 27 18:42:52 2014 -0400 @@ -1125,7 +1125,7 @@ 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 -r 070dfca74610 -r 9f06cbb7962b Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py Thu Mar 27 18:23:03 2014 -0400 +++ b/Lib/test/test_inspect.py Thu Mar 27 18:42:52 2014 -0400 @@ -1214,6 +1214,12 @@ 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): diff -r 070dfca74610 -r 9f06cbb7962b Misc/NEWS --- a/Misc/NEWS Thu Mar 27 18:23:03 2014 -0400 +++ b/Misc/NEWS Thu Mar 27 18:42:52 2014 -0400 @@ -86,6 +86,9 @@ - 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 -------------