[Python-checkins] r64045 - in python/trunk: Lib/test/test_py3kwarn.py Python/ast.c

benjamin.peterson python-checkins at python.org
Mon Jun 9 01:00:11 CEST 2008


Author: benjamin.peterson
Date: Mon Jun  9 01:00:00 2008
New Revision: 64045

Log:
warn about parameter tuple unpacking


Modified:
   python/trunk/Lib/test/test_py3kwarn.py
   python/trunk/Python/ast.c

Modified: python/trunk/Lib/test/test_py3kwarn.py
==============================================================================
--- python/trunk/Lib/test/test_py3kwarn.py	(original)
+++ python/trunk/Lib/test/test_py3kwarn.py	Mon Jun  9 01:00:00 2008
@@ -173,6 +173,12 @@
             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:

Modified: python/trunk/Python/ast.c
==============================================================================
--- python/trunk/Python/ast.c	(original)
+++ python/trunk/Python/ast.c	Mon Jun  9 01:00:00 2008
@@ -701,6 +701,9 @@
                     /* 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;


More information about the Python-checkins mailing list