]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix test_parser.py in a hacky way
authorGuido van Rossum <guido@python.org>
Fri, 25 Jan 2019 20:14:55 +0000 (12:14 -0800)
committerGuido van Rossum <guido@python.org>
Fri, 25 Jan 2019 20:14:55 +0000 (12:14 -0800)
This counteracts a previous commit labeled
"A better hack for IndentationError".

Modules/parsermodule.c

index eabc5c810f6ce6e059557bb3969bd4cb407992d6..87f58d340c2dbeec645e53bb3d0495b7ff6d9431 100644 (file)
@@ -663,6 +663,12 @@ validate_node(node *tree)
     for (pos = 0; pos < nch; ++pos) {
         node *ch = CHILD(tree, pos);
         int ch_type = TYPE(ch);
+        if (ch_type == suite && TYPE(tree) == funcdef) {
+            /* This is the opposite hack of what we do in parser.c
+               (search for func_body_suite), except we don't ever
+               support type comments here. */
+            ch_type = func_body_suite;
+        }
         for (arc = 0; arc < dfa_state->s_narcs; ++arc) {
             short a_label = dfa_state->s_arc[arc].a_lbl;
             assert(a_label < _PyParser_Grammar.g_ll.ll_nlabels);