summaryrefslogtreecommitdiffstats
path: root/Python/Python-ast.c
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-06-30 23:45:08 (GMT)
committerGitHub <noreply@github.com>2023-06-30 23:45:08 (GMT)
commit46c1097868745eeb47abbc8af8c34e8fcb80ff1d (patch)
tree29749fa3f2b4c3364b8024de3decc25cd103fd34 /Python/Python-ast.c
parent904aef994262383ae916545908f0578c2d53cf31 (diff)
downloadcpython-46c1097868745eeb47abbc8af8c34e8fcb80ff1d.zip
cpython-46c1097868745eeb47abbc8af8c34e8fcb80ff1d.tar.gz
cpython-46c1097868745eeb47abbc8af8c34e8fcb80ff1d.tar.bz2
gh-106145: Make `end_{lineno,col_offset}` required on `type_param` nodes (#106224)
Diffstat (limited to 'Python/Python-ast.c')
-rw-r--r--Python/Python-ast.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 1ffb835..5db9ade 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -1902,12 +1902,6 @@ init_types(struct ast_state *state)
if (!state->type_param_type) return 0;
if (!add_attributes(state, state->type_param_type, type_param_attributes,
4)) return 0;
- if (PyObject_SetAttr(state->type_param_type, state->end_lineno, Py_None) ==
- -1)
- return 0;
- if (PyObject_SetAttr(state->type_param_type, state->end_col_offset,
- Py_None) == -1)
- return 0;
state->TypeVar_type = make_type(state, "TypeVar", state->type_param_type,
TypeVar_fields, 2,
"TypeVar(identifier name, expr? bound)");
@@ -12500,9 +12494,9 @@ obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
return 1;
}
- if (tmp == NULL || tmp == Py_None) {
- Py_CLEAR(tmp);
- end_lineno = lineno;
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from type_param");
+ return 1;
}
else {
int res;
@@ -12517,9 +12511,9 @@ obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
return 1;
}
- if (tmp == NULL || tmp == Py_None) {
- Py_CLEAR(tmp);
- end_col_offset = col_offset;
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from type_param");
+ return 1;
}
else {
int res;