8000 [3.12] gh-104799: Move location of type_params AST fields (GH-104828)… · python/cpython@7899fac · GitHub
[go: up one dir, main page]

Skip to content

Commit 7899fac

Browse files
miss-islingtonJelleZijlstraAlexWaygood
authored
[3.12] gh-104799: Move location of type_params AST fields (GH-104828) (#104974)
gh-104799: Move location of type_params AST fields (GH-104828) (cherry picked from commit ba73473) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
1 parent fd6b913 commit 7899fac

File tree

10 files changed

+365
-334
lines changed

10 files changed

+365
-334
lines changed

Doc/data/python3.12.abi

Lines changed: 68 additions & 68 deletions
Large diffs are not rendered by default.

Doc/library/ast.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,6 @@ Function and class definitions
18211821
body=[
18221822
FunctionDef(
18231823
name='f',
1824-
type_params=[],
18251824
args=arguments(
18261825
posonlyargs=[],
18271826
args=[
@@ -1846,7 +1845,8 @@ Function and class definitions
18461845
decorator_list=[
18471846
Name(id='decorator1', ctx=Load()),
18481847
Name(id='decorator2', ctx=Load())],
1849-
returns=Constant(value='return annotation'))],
1848+
returns=Constant(value='return annotation'),
1849+
type_params=[])],
18501850
type_ignores=[])
18511851

18521852

@@ -1943,7 +1943,6 @@ Function and class definitions
19431943
body=[
19441944
ClassDef(
19451945
name='Foo',
1946-
type_params=[],
19471946
bases=[
19481947
Name(id='base1', ctx=Load()),
19491948
Name(id='base2', ctx=Load())],
@@ -1955,7 +1954,8 @@ Function and class definitions
19551954
Pass()],
19561955
decorator_list=[
19571956
Name(id='decorator1', ctx=Load()),
1958-
Name(id='decorator2', ctx=Load())])],
1957+
Name(id='decorator2', ctx=Load())],
1958+
type_params=[])],
19591959
type_ignores=[])
19601960

19611961
Async and await
@@ -1982,7 +1982,6 @@ Async and await
19821982
body=[
19831983
AsyncFunctionDef(
19841984
name='f',
1985-
type_params=[],
19861985
args=arguments(
19871986
posonlyargs=[],
19881987
args=[],
@@ -1996,7 +1995,8 @@ Async and await
19961995
func=Name(id='other_func', ctx=Load()),
19971996
args=[],
19981997
keywords=[])))],
1999-
decorator_list=[])],
1998+
decorator_list=[],
1999+
type_params=[])],
20002000
type_ignores=[])
20012001

20022002

Grammar/python.gram

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,10 @@ class_def[stmt_ty]:
254254
class_def_raw[stmt_ty]:
255255
| invalid_class_def_raw
256256
| 'class' a=NAME t=[type_params] b=['(' z=[arguments] ')' { z }] ':' c=block {
257-
_PyAST_ClassDef(a->v.Name.id, t,
257+
_PyAST_ClassDef(a->v.Name.id,
258258
(b) ? ((expr_ty) b)->v.Call.args : NULL,
259259
(b) ? ((expr_ty) b)->v.Call.keywords : NULL,
260-
c, NULL, EXTRA) }
260+
c, NULL, t, EXTRA) }
261261

262262
# Function definitions
263263
# --------------------
@@ -269,17 +269,17 @@ function_def[stmt_ty]:
269269
function_def_raw[stmt_ty]:
270270
| invalid_def_raw
271271
| 'def' n=NAME t=[type_params] &&'(' params=[params] ')' a=['->' z=expression { z }] &&':' tc=[func_type_comment] b=block {
272-
_PyAST_FunctionDef(n->v.Name.id, t,
272+
_PyAST_FunctionDef(n->v.Name.id,
273273
(params) ? params : CHECK(arguments_ty, _PyPegen_empty_arguments(p)),
274-
b, NULL, a, NEW_TYPE_COMMENT(p, tc), EXTRA) }
274+
b, NULL, a, NEW_TYPE_COMMENT(p, tc), t, EXTRA) }
275275
| ASYNC 'def' n=NAME t=[type_params] &&'(' params=[params] ')' a=['->' z=expression { z }] &&':' tc=[func_type_comment] b=block {
276276
CHECK_VERSION(
277277
stmt_ty,
278278
5,
279279
"Async functions are",
280-
_PyAST_AsyncFunctionDef(n->v.Name.id, t,
280+
_PyAST_AsyncFunctionDef(n->v.Name.id,
281281
(params) ? params : CHECK(arguments_ty, _PyPegen_empty_arguments(p)),
282-
b, NULL, a, NEW_TYPE_COMMENT(p, tc), EXTRA)
282+
b, NULL, a, NEW_TYPE_COMMENT(p, tc), t, EXTRA)
283283
) }
284284

285285
# Function parameters

Include/internal/pycore_ast.h

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0