]> granicus.if.org Git - python/commitdiff
#3117: backport r55087, fixes segfault with lambda (None,): None.
authorGeorg Brandl <georg@python.org>
Sun, 15 Jun 2008 19:53:12 +0000 (19:53 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 15 Jun 2008 19:53:12 +0000 (19:53 +0000)
Lib/test/test_grammar.py
Python/ast.c

index 6a9e5124c690050a74dc29243c30b060a1c23fa7..09ccde7002d8aa1019bce449b413d9b0f142ae57 100644 (file)
@@ -277,6 +277,7 @@ l5 = lambda x, y, z=2: x + y + z
 verify(l5(1, 2) == 5)
 verify(l5(1, 2, 3) == 6)
 check_syntax("lambda x: x = 2")
+check_syntax("lambda (None,): None")
 
 ### stmt: simple_stmt | compound_stmt
 # Tested below
index c7fd8bcc9604cfecd8ead0da6bde2fbea6bed935..057b64df32583dfafba6cb19a9fce0b79d0393fd 100644 (file)
@@ -249,6 +249,8 @@ PyAST_FromNode(const node *n, PyCompilerFlags *flags, const char *filename,
                    goto error;
                 asdl_seq_SET(stmts, 0, Pass(n->n_lineno, n->n_col_offset,
                                             arena));
+                if (!asdl_seq_GET(stmts, 0))
+                    goto error;
                 return Interactive(stmts, arena);
             }
             else {
@@ -679,6 +681,8 @@ ast_for_arguments(struct compiling *c, const node *n)
                    if (NCH(ch) != 1) {
                        /* We have complex arguments, setup for unpacking. */
                        asdl_seq_SET(args, k++, compiler_complex_args(c, ch));
+                       if (!asdl_seq_GET(args, k-1))
+                           goto error;
                    } else {
                        /* def foo((x)): setup for checking NAME below. */
                        /* Loop because there can be many parens and tuple