GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Error handling bugs in ast.c · Issue #104482 · python/cpython

Error handling bugs in ast.c #104482

New issue
Copy link
New issue
Copy link
Closed
#104483
Closed
Error handling bugs in ast.c#104482
#104483
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@iritkatriel
iritkatriel
opened on May 14, 2023
Issue body actions

in validate_pattern, there are two places where in case of error we break out of a loop, but we also need to break out of the switch.

--- a/Python/ast.c
+++ b/Python/ast.c
@@ -580,7 +580,9 @@ validate_pattern(struct validator *state, pattern_ty p, int star_ok)
                     break;
                 }
             }
-
+            if (ret == 0) {
+                break;
+            }
             ret = validate_patterns(state, p->v.MatchMapping.patterns, /*star_ok=*/0);
             break;
         case MatchClass_kind:
@@ -620,6 +622,9 @@ validate_pattern(struct validator *state, pattern_ty p, int star_ok)
                 }
             }
 
+            if (ret == 0) {
+                break;
+            }
             if (!validate_patterns(state, p->v.MatchClass.patterns, /*star_ok=*/0)) {
                 ret = 0;
                 break;

If we don't do this we can end up calling _PyAST_Compile with an error set.

Linked PRs

  • gh-104482: Fix error handling bugs in ast.c #104483
  • [3.11] gh-104482: Fix error handling bugs in ast.c #104514

Activity

  1. iritkatriel
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on May 14, 2023
  2. iritkatriel
    added a commit that references this issue on May 14, 2023

    pythongh-104482: Fix error handling bugs in ast.c

    5a4e346
  3. iritkatriel
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on May 14, 2023
  4. iritkatriel
    closed this as completedin #104483on May 15, 2023
  5. iritkatriel
    added 3 commits that reference this issue on May 15, 2023

    gh-104482: Fix error handling bugs in ast.c (#104483)

    8a3702f

    [3.11] pythongh-104482: Fix error handling bugs in ast.c

    6e02b76

    [3.11] gh-104482: Fix error handling bugs in ast.c (#104514)

    52a18fe
  6. carljm
    added a commit that references this issue on May 16, 2023

    Merge branch 'main' into supermon

    a6dd626
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.