bpo-46707: Avoid potential exponential backtracking in some syntax errors (GH-31241)

4 files changed