From f4fcdb6b8c0ee8bc4d2eee5ea3b848a4cd905ad6 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 8 Jun 2008 23:00:00 +0000 Subject: warn about parameter tuple unpacking --- Lib/test/test_py3kwarn.py | 6 ++++++ Python/ast.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py index 18298fe..768be28 100644 --- a/Lib/test/test_py3kwarn.py +++ b/Lib/test/test_py3kwarn.py @@ -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: diff --git a/Python/ast.c b/Python/ast.c index ab166e8..ef0d8be 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -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; -- cgit v0.12