]> granicus.if.org Git - python/commitdiff
warn about parameter tuple unpacking
authorBenjamin Peterson <benjamin@python.org>
Sun, 8 Jun 2008 23:00:00 +0000 (23:00 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sun, 8 Jun 2008 23:00:00 +0000 (23:00 +0000)
Lib/test/test_py3kwarn.py
Python/ast.c

index 18298fef3d1bf0ab6b06989cd7863cc5c89b5786..768be285f9707a0f13f62e0be6ed30f0bd011cb5 100644 (file)
@@ -173,6 +173,12 @@ class TestPy3KWarnings(unittest.TestCase):
             with catch_warning() as w:
                 self.assertWarning(set(), w, expected)
 
+    def test_tuple_parameter_unpacking(self):
+        expected = "tuple parameter unpacking has been removed in 3.x"
+        with catch_warning() as w:
+            exec "def f((a, b)): pass"
+            self.assertWarning(None, w, expected)
+
     def test_buffer(self):
         expected = 'buffer() not supported in 3.x; use memoryview()'
         with catch_warning() as w:
index ab166e816ab8306dcf60c4f530ab6460d1c3595b..ef0d8bedcf15660e8535eb1d23eccdcfabaf2622 100644 (file)
@@ -701,6 +701,9 @@ ast_for_arguments(struct compiling *c, const node *n)
                     /* def foo((x)): is not complex, special case. */
                     if (NCH(ch) != 1) {
                         /* We have complex arguments, setup for unpacking. */
+                        if (Py_Py3kWarningFlag && !ast_warn(c, ch,
+                            "tuple parameter unpacking has been removed in 3.x"))
+                            goto error;
                         asdl_seq_SET(args, k++, compiler_complex_args(c, ch));
                         if (!asdl_seq_GET(args, k-1))
                                 goto error;