summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-07-01 00:15:18 (GMT)
committerGitHub <noreply@github.com>2023-07-01 00:15:18 (GMT)
commit0616c83f57a8d2fd62d12ddaba987052c5015260 (patch)
tree8977e6011ae7b1e69e0ef949a5ff4f2f6c68b85e /Python
parentd6a5a30669b1bb383f05208299fa911720d4d88b (diff)
downloadcpython-0616c83f57a8d2fd62d12ddaba987052c5015260.zip
cpython-0616c83f57a8d2fd62d12ddaba987052c5015260.tar.gz
cpython-0616c83f57a8d2fd62d12ddaba987052c5015260.tar.bz2
[3.12] gh-106145: Make `end_{lineno,col_offset}` required on `type_param` nodes (GH-106224) (#106295)
gh-106145: Make `end_{lineno,col_offset}` required on `type_param` nodes (GH-106224) (cherry picked from commit 46c1097868745eeb47abbc8af8c34e8fcb80ff1d) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Diffstat (limited to 'Python')
-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;