summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_grammar.py4
-rw-r--r--Lib/test/test_inspect.py6
-rw-r--r--Python/ast.c15
3 files changed, 19 insertions, 6 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 5b20ab3..45e3c49 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -255,6 +255,10 @@ d22v(1, 2, 3, 4, 5)
d22v(*(1, 2, 3, 4))
d22v(1, 2, *(3, 4, 5))
d22v(1, *(2, 3), **{'d': 4})
+def d31v((x)): pass
+d31v(1)
+def d32v((x,)): pass
+d32v((1,))
### lambdef: 'lambda' [varargslist] ':' test
print 'lambdef'
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index ce346b9..79be369 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -304,10 +304,12 @@ class TestClassesAndFunctions(unittest.TestCase):
self.assertArgSpecEquals(A.m, ['self'])
def test_getargspec_sublistofone(self):
- def sublistOfOne((foo)): return 1
-
+ def sublistOfOne((foo,)): return 1
self.assertArgSpecEquals(sublistOfOne, [['foo']])
+ def fakeSublistOfOne((foo)): return 1
+ self.assertArgSpecEquals(fakeSublistOfOne, ['foo'])
+
def test_classify_oldstyle(self):
class A:
def s(): pass
diff --git a/Python/ast.c b/Python/ast.c
index 30275a6..86f3d3c 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -645,10 +645,17 @@ ast_for_arguments(struct compiling *c, const node *n)
goto error;
}
if (NCH(ch) == 3) {
- asdl_seq_SET(args, k++,
- compiler_complex_args(c, CHILD(ch, 1)));
- }
- else if (TYPE(CHILD(ch, 0)) == NAME) {
+ ch = CHILD(ch, 1);
+ /* def foo((x)): is not complex, special case. */
+ if (NCH(ch) != 1) {
+ /* We have complex arguments, setup for unpacking. */
+ asdl_seq_SET(args, k++, compiler_complex_args(c, ch));
+ } else {
+ /* def foo((x)): setup for checking NAME below. */
+ ch = CHILD(ch, 0);
+ }
+ }
+ if (TYPE(CHILD(ch, 0)) == NAME) {
expr_ty name;
if (!strcmp(STR(CHILD(ch, 0)), "None")) {
ast_error(CHILD(ch, 0), "assignment to None");