summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-08-19 20:57:10 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-08-19 20:57:10 (GMT)
commit2d735bc09876e8216bf6708bb598923e07a2ac4b (patch)
treeb242296c96c8988ba3c783474c960432d13bef67 /Lib
parentde0de885f77d40ddb7e9f2afc8be5a99b9cf01ec (diff)
downloadcpython-2d735bc09876e8216bf6708bb598923e07a2ac4b.zip
cpython-2d735bc09876e8216bf6708bb598923e07a2ac4b.tar.gz
cpython-2d735bc09876e8216bf6708bb598923e07a2ac4b.tar.bz2
allow keyword args after *args in a function call
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_grammar.py8
-rw-r--r--Lib/test/test_keywordonlyarg.py2
2 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index acfe1f1..9a88463 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -284,6 +284,14 @@ class GrammarTests(unittest.TestCase):
pos2key2dict(1,2,k2=100,tokwarg1=100,tokwarg2=200)
pos2key2dict(1,2,tokwarg1=100,tokwarg2=200, k2=100)
+ # keyword arguments after *arglist
+ def f(*args, **kwargs):
+ return args, kwargs
+ self.assertEquals(f(1, x=2, *[3, 4], y=5), ((1, 3, 4),
+ {'x':2, 'y':5}))
+ self.assertRaises(SyntaxError, eval, "f(1, *(2,3), 4)")
+ self.assertRaises(SyntaxError, eval, "f(1, x=2, *(3,4), x=5)")
+
# argument annotation tests
def f(x) -> list: pass
self.assertEquals(f.__annotations__, {'return': list})
diff --git a/Lib/test/test_keywordonlyarg.py b/Lib/test/test_keywordonlyarg.py
index aa7d3db..b771a6c 100644
--- a/Lib/test/test_keywordonlyarg.py
+++ b/Lib/test/test_keywordonlyarg.py
@@ -75,7 +75,7 @@ class KeywordOnlyArgTestCase(unittest.TestCase):
def testSyntaxErrorForFunctionCall(self):
self.assertRaisesSyntaxError("f(p, k=1, p2)")
- self.assertRaisesSyntaxError("f(p, *(1,2), k1=100)")
+ self.assertRaisesSyntaxError("f(p, k1=50, *(1,2), k1=100)")
def testRaiseErrorFuncallWithUnexpectedKeywordArgument(self):
self.assertRaises(TypeError, keywordonly_sum, ())