improve several corner cases related with argument names in parenthesis
- Fix #7362: give a good error message for parenthesized arguments with
defaults.
- Add a py3k warning for any parenthesized arguments since those are not allowed
in Py3. This warning is not given in tuple unpacking, since that incurs the
tuple unpacking warning.
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 26d78ad..2118c62 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -493,10 +493,14 @@
self.fail("SyntaxError is not a %s" % subclass.__name__)
mo = re.search(errtext, str(err))
if mo is None:
- self.fail("SyntaxError did not contain '%r'" % (errtext,))
+ self.fail("%s did not contain '%r'" % (err, errtext,))
else:
self.fail("compile() did not raise SyntaxError")
+ def test_paren_arg_with_default(self):
+ self._check_error("def f((x)=23): pass",
+ "parenthesized arg with default")
+
def test_assign_call(self):
self._check_error("f() = 1", "assign")