Skip to content

Commit 24cd768

Browse files
committed
gh-159672: Remove obsolete keyword typo support
1 parent 30d8199 commit 24cd768

6 files changed

Lines changed: 458 additions & 546 deletions

File tree

‎Grammar/python.gram‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,11 @@ func_type[mod_ty]: '(' a=[type_expressions] ')' '->' b=expression NEWLINE* ENDMA
9797
statements[asdl_stmt_seq*]: a=statement+ { (asdl_stmt_seq*)_PyPegen_seq_flatten(p, a) }
9898

9999
statement[asdl_stmt_seq*]:
100-
| a=compound_stmt { _PyPegen_register_stmts(p ,
101-
(asdl_stmt_seq*)_PyPegen_singleton_seq(p, a)
102-
) }
100+
| a=compound_stmt { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) }
103101
| a[asdl_stmt_seq*]=simple_stmts { a }
104102

105-
single_compound_stmt[asdl_stmt_seq*]:
106-
| a=compound_stmt {
107-
_PyPegen_register_stmts(p, (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a)) }
108-
109103
statement_newline[asdl_stmt_seq*]:
110-
| a=single_compound_stmt NEWLINE { a }
104+
| a=compound_stmt NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) }
111105
| simple_stmts
112106
| NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, CHECK(stmt_ty, _PyAST_Pass(EXTRA))) }
113107
| ENDMARKER { _PyPegen_interactive_exit(p) }

‎Lib/codeop.py‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
PyCF_ONLY_AST = 0x400
4848
PyCF_ALLOW_INCOMPLETE_INPUT = 0x4000
4949

50-
def _maybe_compile(compiler, source, filename, symbol, flags):
50+
def _maybe_compile(compiler, source, filename, symbol):
5151
# Check for source consisting of only blank lines and comments.
5252
for line in source.split("\n"):
5353
line = line.strip()
@@ -61,21 +61,22 @@ def _maybe_compile(compiler, source, filename, symbol, flags):
6161
with warnings.catch_warnings():
6262
warnings.simplefilter("ignore", (SyntaxWarning, DeprecationWarning))
6363
try:
64-
compiler(source, filename, symbol, flags=flags)
64+
compiler(source, filename, symbol)
6565
except _IncompleteInputError:
6666
return None
6767
except SyntaxError: # Let other compile() errors propagate.
6868
pass
6969

7070
return compiler(source, filename, symbol, incomplete_input=False)
7171

72-
def _compile(source, filename, symbol, incomplete_input=True, *, flags=0):
72+
def _compile(source, filename, symbol, incomplete_input=True):
73+
flags = 0
7374
if incomplete_input:
7475
flags |= PyCF_ALLOW_INCOMPLETE_INPUT
7576
flags |= PyCF_DONT_IMPLY_DEDENT
7677
return compile(source, filename, symbol, flags)
7778

78-
def compile_command(source, filename="<input>", symbol="single", flags=0):
79+
def compile_command(source, filename="<input>", symbol="single"):
7980
r"""Compile a command and determine whether it is incomplete.
8081
8182
Arguments:
@@ -94,7 +95,7 @@ def compile_command(source, filename="<input>", symbol="single", flags=0):
9495
syntax error (OverflowError and ValueError can be produced by
9596
malformed literals).
9697
"""
97-
return _maybe_compile(_compile, source, filename, symbol, flags)
98+
return _maybe_compile(_compile, source, filename, symbol)
9899

99100
class Compile:
100101
"""Instances of this class behave much like the built-in compile
@@ -146,4 +147,4 @@ def __call__(self, source, filename="<input>", symbol="single"):
146147
syntax error (OverflowError and ValueError can be produced by
147148
malformed literals).
148149
"""
149-
return _maybe_compile(self.compiler, source, filename, symbol, flags=self.compiler.flags)
150+
return _maybe_compile(self.compiler, source, filename, symbol)

‎Parser/action_helpers.c‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,23 +2152,3 @@ _PyPegen_checked_from_import(Parser *p, asdl_seq *dots, expr_ty module_name,
21522152
return _PyAST_ImportFrom(module, names, level, lazy_token ? 1 : 0, lineno,
21532153
col_offset, end_lineno, end_col_offset, arena);
21542154
}
2155-
2156-
asdl_stmt_seq*
2157-
_PyPegen_register_stmts(Parser *p, asdl_stmt_seq* stmts) {
2158-
if (!p->call_invalid_rules) {
2159-
return stmts;
2160-
}
2161-
Py_ssize_t len = asdl_seq_LEN(stmts);
2162-
if (len == 0) {
2163-
return stmts;
2164-
}
2165-
stmt_ty last_stmt = asdl_seq_GET(stmts, len - 1);
2166-
if (p->last_stmt_location.lineno > last_stmt->lineno) {
2167-
return stmts;
2168-
}
2169-
p->last_stmt_location.lineno = last_stmt->lineno;
2170-
p->last_stmt_location.col_offset = last_stmt->col_offset;
2171-
p->last_stmt_location.end_lineno = last_stmt->end_lineno;
2172-
p->last_stmt_location.end_col_offset = last_stmt->end_col_offset;
2173-
return stmts;
2174-
}

0 commit comments

Comments
 (0)