aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-07-12 08:57:10 +0300
committerGitHub <noreply@github.com>2023-07-12 08:57:10 +0300
commitbe1b968dc1e63c3c68e161ddc5a05eb064833440 (patch)
tree8689ba9f656854b83bf24b82de4fc471437a51ab /Python
parente8ab0096a583184fe24dfbc39eff70d270c8e6f4 (diff)
downloadcpython-be1b968dc1e63c3c68e161ddc5a05eb064833440.tar.gz
cpython-be1b968dc1e63c3c68e161ddc5a05eb064833440.zip
gh-106521: Remove _PyObject_LookupAttr() function (GH-106642)
Diffstat (limited to 'Python')
-rw-r--r--Python/Python-ast.c444
-rw-r--r--Python/_warnings.c4
-rw-r--r--Python/bltinmodule.c10
-rw-r--r--Python/ceval.c6
-rw-r--r--Python/codecs.c2
-rw-r--r--Python/errors.c4
-rw-r--r--Python/import.c2
-rw-r--r--Python/intrinsics.c4
-rw-r--r--Python/pythonrun.c4
-rw-r--r--Python/suggestions.c2
-rw-r--r--Python/sysmodule.c4
11 files changed, 243 insertions, 243 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 5db9ade3af4..55a1370fbd0 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -839,7 +839,7 @@ ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
Py_ssize_t i, numfields = 0;
int res = -1;
PyObject *key, *value, *fields;
- if (_PyObject_LookupAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
+ if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
goto cleanup;
}
if (fields) {
@@ -913,7 +913,7 @@ ast_type_reduce(PyObject *self, PyObject *unused)
}
PyObject *dict;
- if (_PyObject_LookupAttr(self, state->__dict__, &dict) < 0) {
+ if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
return NULL;
}
if (dict) {
@@ -5750,7 +5750,7 @@ obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
asdl_stmt_seq* body;
asdl_type_ignore_seq* type_ignores;
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -5788,7 +5788,7 @@ obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->type_ignores, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->type_ignores, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -5838,7 +5838,7 @@ obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
if (isinstance) {
asdl_stmt_seq* body;
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -5888,7 +5888,7 @@ obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
if (isinstance) {
expr_ty body;
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -5918,7 +5918,7 @@ obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
asdl_expr_seq* argtypes;
expr_ty returns;
- if (_PyObject_LookupAttr(obj, state->argtypes, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->argtypes, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -5956,7 +5956,7 @@ obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->returns, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6001,7 +6001,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
*out = NULL;
return 0;
}
- if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6018,7 +6018,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6035,7 +6035,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -6052,7 +6052,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -6083,7 +6083,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
string type_comment;
asdl_type_param_seq* type_params;
- if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6100,7 +6100,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6117,7 +6117,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6155,7 +6155,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->decorator_list, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6193,7 +6193,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->returns, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -6210,7 +6210,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -6227,7 +6227,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->type_params, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6286,7 +6286,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
string type_comment;
asdl_type_param_seq* type_params;
- if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6303,7 +6303,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6320,7 +6320,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6358,7 +6358,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->decorator_list, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6396,7 +6396,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->returns, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -6413,7 +6413,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -6430,7 +6430,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->type_params, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6488,7 +6488,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
asdl_expr_seq* decorator_list;
asdl_type_param_seq* type_params;
- if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6505,7 +6505,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->bases, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->bases, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6543,7 +6543,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->keywords, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6581,7 +6581,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6619,7 +6619,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->decorator_list, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6657,7 +6657,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->type_params, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6709,7 +6709,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (isinstance) {
expr_ty value;
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -6739,7 +6739,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (isinstance) {
asdl_expr_seq* targets;
- if (_PyObject_LookupAttr(obj, state->targets, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6792,7 +6792,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
expr_ty value;
string type_comment;
- if (_PyObject_LookupAttr(obj, state->targets, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6830,7 +6830,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6847,7 +6847,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -6879,7 +6879,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
asdl_type_param_seq* type_params;
expr_ty value;
- if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6896,7 +6896,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->type_params, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6934,7 +6934,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6966,7 +6966,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
operator_ty op;
expr_ty value;
- if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -6983,7 +6983,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7000,7 +7000,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7033,7 +7033,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
expr_ty value;
int simple;
- if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7050,7 +7050,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->annotation, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7067,7 +7067,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -7084,7 +7084,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->simple, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->simple, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7118,7 +7118,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
asdl_stmt_seq* orelse;
string type_comment;
- if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7135,7 +7135,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->iter, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7152,7 +7152,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7190,7 +7190,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7228,7 +7228,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -7262,7 +7262,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
asdl_stmt_seq* orelse;
string type_comment;
- if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7279,7 +7279,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->iter, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7296,7 +7296,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7334,7 +7334,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7372,7 +7372,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -7405,7 +7405,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
asdl_stmt_seq* body;
asdl_stmt_seq* orelse;
- if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7422,7 +7422,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7460,7 +7460,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7513,7 +7513,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
asdl_stmt_seq* body;
asdl_stmt_seq* orelse;
- if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7530,7 +7530,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7568,7 +7568,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7621,7 +7621,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
asdl_stmt_seq* body;
string type_comment;
- if (_PyObject_LookupAttr(obj, state->items, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7659,7 +7659,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7697,7 +7697,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -7729,7 +7729,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
asdl_stmt_seq* body;
string type_comment;
- if (_PyObject_LookupAttr(obj, state->items, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7767,7 +7767,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7805,7 +7805,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -7836,7 +7836,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
expr_ty subject;
asdl_match_case_seq* cases;
- if (_PyObject_LookupAttr(obj, state->subject, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->subject, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7853,7 +7853,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->cases, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->cases, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7905,7 +7905,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
expr_ty exc;
expr_ty cause;
- if (_PyObject_LookupAttr(obj, state->exc, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->exc, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -7922,7 +7922,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->cause, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->cause, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -7955,7 +7955,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
asdl_stmt_seq* orelse;
asdl_stmt_seq* finalbody;
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -7993,7 +7993,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->handlers, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8031,7 +8031,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8069,7 +8069,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->finalbody, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8123,7 +8123,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
asdl_stmt_seq* orelse;
asdl_stmt_seq* finalbody;
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8161,7 +8161,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->handlers, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8199,7 +8199,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8237,7 +8237,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->finalbody, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8289,7 +8289,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
expr_ty test;
expr_ty msg;
- if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8306,7 +8306,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->msg, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->msg, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -8336,7 +8336,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (isinstance) {
asdl_alias_seq* names;
- if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8389,7 +8389,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
asdl_alias_seq* names;
int level;
- if (_PyObject_LookupAttr(obj, state->module, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->module, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -8406,7 +8406,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8444,7 +8444,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->level, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->level, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -8474,7 +8474,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (isinstance) {
asdl_identifier_seq* names;
- if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8525,7 +8525,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (isinstance) {
asdl_identifier_seq* names;
- if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8576,7 +8576,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
if (isinstance) {
expr_ty value;
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8658,7 +8658,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
*out = NULL;
return 0;
}
- if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8675,7 +8675,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8692,7 +8692,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -8709,7 +8709,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -8735,7 +8735,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
boolop_ty op;
asdl_expr_seq* values;
- if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8752,7 +8752,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8804,7 +8804,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
expr_ty target;
expr_ty value;
- if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8821,7 +8821,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8853,7 +8853,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
operator_ty op;
expr_ty right;
- if (_PyObject_LookupAttr(obj, state->left, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8870,7 +8870,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8887,7 +8887,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->right, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->right, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8918,7 +8918,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
unaryop_ty op;
expr_ty operand;
- if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8935,7 +8935,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->operand, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->operand, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8966,7 +8966,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
arguments_ty args;
expr_ty body;
- if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -8983,7 +8983,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9015,7 +9015,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
expr_ty body;
expr_ty orelse;
- if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9032,7 +9032,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9049,7 +9049,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9080,7 +9080,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
asdl_expr_seq* keys;
asdl_expr_seq* values;
- if (_PyObject_LookupAttr(obj, state->keys, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9118,7 +9118,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9169,7 +9169,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (isinstance) {
asdl_expr_seq* elts;
- if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9221,7 +9221,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
expr_ty elt;
asdl_comprehension_seq* generators;
- if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9238,7 +9238,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9290,7 +9290,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
expr_ty elt;
asdl_comprehension_seq* generators;
- if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9307,7 +9307,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9360,7 +9360,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
expr_ty value;
asdl_comprehension_seq* generators;
- if (_PyObject_LookupAttr(obj, state->key, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->key, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9377,7 +9377,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9394,7 +9394,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9446,7 +9446,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
expr_ty elt;
asdl_comprehension_seq* generators;
- if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9463,7 +9463,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9514,7 +9514,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (isinstance) {
expr_ty value;
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9544,7 +9544,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (isinstance) {
expr_ty value;
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -9574,7 +9574,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (isinstance) {
expr_ty value;
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9606,7 +9606,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
asdl_int_seq* ops;
asdl_expr_seq* comparators;
- if (_PyObject_LookupAttr(obj, state->left, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9623,7 +9623,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->ops, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->ops, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9661,7 +9661,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->comparators, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->comparators, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9714,7 +9714,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
asdl_expr_seq* args;
asdl_keyword_seq* keywords;
- if (_PyObject_LookupAttr(obj, state->func, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->func, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9731,7 +9731,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9769,7 +9769,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->keywords, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9822,7 +9822,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
int conversion;
expr_ty format_spec;
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9839,7 +9839,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->conversion, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9856,7 +9856,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->format_spec, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -9887,7 +9887,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (isinstance) {
asdl_expr_seq* values;
- if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9939,7 +9939,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
constant value;
string kind;
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -9956,7 +9956,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->kind, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->kind, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -9988,7 +9988,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
identifier attr;
expr_context_ty ctx;
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10005,7 +10005,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->attr, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->attr, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10022,7 +10022,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10054,7 +10054,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
expr_ty slice;
expr_context_ty ctx;
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10071,7 +10071,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->slice, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->slice, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10088,7 +10088,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10119,7 +10119,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
expr_ty value;
expr_context_ty ctx;
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10136,7 +10136,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10167,7 +10167,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
identifier id;
expr_context_ty ctx;
- if (_PyObject_LookupAttr(obj, state->id, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->id, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10184,7 +10184,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10215,7 +10215,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
asdl_expr_seq* elts;
expr_context_ty ctx;
- if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10253,7 +10253,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10284,7 +10284,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
asdl_expr_seq* elts;
expr_context_ty ctx;
- if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10322,7 +10322,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10354,7 +10354,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
expr_ty upper;
expr_ty step;
- if (_PyObject_LookupAttr(obj, state->lower, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->lower, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -10371,7 +10371,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->upper, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->upper, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -10388,7 +10388,7 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->step, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->step, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -10738,7 +10738,7 @@ obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
asdl_expr_seq* ifs;
int is_async;
- if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10755,7 +10755,7 @@ obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->iter, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10772,7 +10772,7 @@ obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->ifs, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->ifs, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10810,7 +10810,7 @@ obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->is_async, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->is_async, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10852,7 +10852,7 @@ obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
*out = NULL;
return 0;
}
- if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10869,7 +10869,7 @@ obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -10886,7 +10886,7 @@ obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -10903,7 +10903,7 @@ obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -10930,7 +10930,7 @@ obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
identifier name;
asdl_stmt_seq* body;
- if (_PyObject_LookupAttr(obj, state->type, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->type, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -10947,7 +10947,7 @@ obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -10964,7 +10964,7 @@ obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11027,7 +11027,7 @@ obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
arg_ty kwarg;
asdl_expr_seq* defaults;
- if (_PyObject_LookupAttr(obj, state->posonlyargs, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->posonlyargs, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11065,7 +11065,7 @@ obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11103,7 +11103,7 @@ obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->vararg, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->vararg, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -11120,7 +11120,7 @@ obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->kwonlyargs, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->kwonlyargs, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11158,7 +11158,7 @@ obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->kw_defaults, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->kw_defaults, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11196,7 +11196,7 @@ obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->kwarg, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->kwarg, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -11213,7 +11213,7 @@ obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->defaults, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->defaults, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11272,7 +11272,7 @@ obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
int end_lineno;
int end_col_offset;
- if (_PyObject_LookupAttr(obj, state->arg, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11289,7 +11289,7 @@ obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->annotation, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -11306,7 +11306,7 @@ obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -11323,7 +11323,7 @@ obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11340,7 +11340,7 @@ obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11357,7 +11357,7 @@ obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -11374,7 +11374,7 @@ obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -11412,7 +11412,7 @@ obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
int end_lineno;
int end_col_offset;
- if (_PyObject_LookupAttr(obj, state->arg, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -11429,7 +11429,7 @@ obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11446,7 +11446,7 @@ obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11463,7 +11463,7 @@ obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11480,7 +11480,7 @@ obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -11497,7 +11497,7 @@ obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -11535,7 +11535,7 @@ obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
int end_lineno;
int end_col_offset;
- if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11552,7 +11552,7 @@ obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->asname, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->asname, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -11569,7 +11569,7 @@ obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11586,7 +11586,7 @@ obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11603,7 +11603,7 @@ obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -11620,7 +11620,7 @@ obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -11654,7 +11654,7 @@ obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
expr_ty context_expr;
expr_ty optional_vars;
- if (_PyObject_LookupAttr(obj, state->context_expr, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->context_expr, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11671,7 +11671,7 @@ obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->optional_vars, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->optional_vars, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -11705,7 +11705,7 @@ obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
expr_ty guard;
asdl_stmt_seq* body;
- if (_PyObject_LookupAttr(obj, state->pattern, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11722,7 +11722,7 @@ obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->guard, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->guard, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -11739,7 +11739,7 @@ obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11802,7 +11802,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
*out = NULL;
return 0;
}
- if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11819,7 +11819,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11836,7 +11836,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11853,7 +11853,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11878,7 +11878,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
if (isinstance) {
expr_ty value;
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11908,7 +11908,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
if (isinstance) {
constant value;
- if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11938,7 +11938,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
if (isinstance) {
asdl_pattern_seq* patterns;
- if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -11991,7 +11991,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
asdl_pattern_seq* patterns;
identifier rest;
- if (_PyObject_LookupAttr(obj, state->keys, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -12029,7 +12029,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -12067,7 +12067,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->rest, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->rest, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -12100,7 +12100,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
asdl_identifier_seq* kwd_attrs;
asdl_pattern_seq* kwd_patterns;
- if (_PyObject_LookupAttr(obj, state->cls, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->cls, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -12117,7 +12117,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -12155,7 +12155,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->kwd_attrs, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->kwd_attrs, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -12193,7 +12193,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
}
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->kwd_patterns, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->kwd_patterns, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -12245,7 +12245,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
if (isinstance) {
identifier name;
- if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -12276,7 +12276,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
pattern_ty pattern;
identifier name;
- if (_PyObject_LookupAttr(obj, state->pattern, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -12293,7 +12293,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -12323,7 +12323,7 @@ obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
if (isinstance) {
asdl_pattern_seq* patterns;
- if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -12395,7 +12395,7 @@ obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
int lineno;
string tag;
- if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -12412,7 +12412,7 @@ obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->tag, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->tag, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -12457,7 +12457,7 @@ obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
*out = NULL;
return 0;
}
- if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -12474,7 +12474,7 @@ obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -12491,7 +12491,7 @@ obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -12508,7 +12508,7 @@ obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -12534,7 +12534,7 @@ obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
identifier name;
expr_ty bound;
- if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -12551,7 +12551,7 @@ obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- if (_PyObject_LookupAttr(obj, state->bound, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->bound, &tmp) < 0) {
return 1;
}
if (tmp == NULL || tmp == Py_None) {
@@ -12581,7 +12581,7 @@ obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
if (isinstance) {
identifier name;
- if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
@@ -12611,7 +12611,7 @@ obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
if (isinstance) {
identifier name;
- if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
return 1;
}
if (tmp == NULL) {
diff --git a/Python/_warnings.c b/Python/_warnings.c
index e0580f01d93..82e621243a0 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -223,7 +223,7 @@ get_warnings_attr(PyInterpreterState *interp, PyObject *attr, int try_import)
return NULL;
}
- (void)_PyObject_LookupAttr(warnings_module, attr, &obj);
+ (void)PyObject_GetOptionalAttr(warnings_module, attr, &obj);
Py_DECREF(warnings_module);
return obj;
}
@@ -1069,7 +1069,7 @@ get_source_line(PyInterpreterState *interp, PyObject *module_globals, int lineno
Py_INCREF(module_name);
/* Make sure the loader implements the optional get_source() method. */
- (void)_PyObject_LookupAttr(loader, &_Py_ID(get_source), &get_source);
+ (void)PyObject_GetOptionalAttr(loader, &_Py_ID(get_source), &get_source);
Py_DECREF(loader);
if (!get_source) {
Py_DECREF(module_name);
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 20a86fc6f58..7d77fd5c0c3 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -34,7 +34,7 @@ update_bases(PyObject *bases, PyObject *const *args, Py_ssize_t nargs)
}
continue;
}
- if (_PyObject_LookupAttr(base, &_Py_ID(__mro_entries__), &meth) < 0) {
+ if (PyObject_GetOptionalAttr(base, &_Py_ID(__mro_entries__), &meth) < 0) {
goto error;
}
if (!meth) {
@@ -175,7 +175,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs,
}
/* else: meta is not a class, so we cannot do the metaclass
calculation, so we will use the explicitly given object as it is */
- if (_PyObject_LookupAttr(meta, &_Py_ID(__prepare__), &prep) < 0) {
+ if (PyObject_GetOptionalAttr(meta, &_Py_ID(__prepare__), &prep) < 0) {
ns = NULL;
}
else if (prep == NULL) {
@@ -1160,7 +1160,7 @@ builtin_getattr_impl(PyObject *module, PyObject *object, PyObject *name,
PyObject *result;
if (default_value != NULL) {
- if (_PyObject_LookupAttr(object, name, &result) == 0) {
+ if (PyObject_GetOptionalAttr(object, name, &result) == 0) {
return Py_NewRef(default_value);
}
}
@@ -1209,7 +1209,7 @@ builtin_hasattr_impl(PyObject *module, PyObject *obj, PyObject *name)
{
PyObject *v;
- if (_PyObject_LookupAttr(obj, name, &v) < 0) {
+ if (PyObject_GetOptionalAttr(obj, name, &v) < 0) {
return NULL;
}
if (v == NULL) {
@@ -2465,7 +2465,7 @@ builtin_vars_impl(PyObject *module, PyObject *object)
d = _PyEval_GetFrameLocals();
}
else {
- if (_PyObject_LookupAttr(object, &_Py_ID(__dict__), &d) == 0) {
+ if (PyObject_GetOptionalAttr(object, &_Py_ID(__dict__), &d) == 0) {
PyErr_SetString(PyExc_TypeError,
"vars() argument must have __dict__ attribute");
}
diff --git a/Python/ceval.c b/Python/ceval.c
index 57e478c1313..63150a9456b 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -419,7 +419,7 @@ match_class_attr(PyThreadState *tstate, PyObject *subject, PyObject *type,
return NULL;
}
PyObject *attr;
- (void)_PyObject_LookupAttr(subject, name, &attr);
+ (void)PyObject_GetOptionalAttr(subject, name, &attr);
return attr;
}
@@ -454,7 +454,7 @@ match_class(PyThreadState *tstate, PyObject *subject, PyObject *type,
// First, the positional subpatterns:
if (nargs) {
int match_self = 0;
- if (_PyObject_LookupAttr(type, &_Py_ID(__match_args__), &match_args) < 0) {
+ if (PyObject_GetOptionalAttr(type, &_Py_ID(__match_args__), &match_args) < 0) {
goto fail;
}
if (match_args) {
@@ -2414,7 +2414,7 @@ import_from(PyThreadState *tstate, PyObject *v, PyObject *name)
PyObject *x;
PyObject *fullmodname, *pkgname, *pkgpath, *pkgname_or_unknown, *errmsg;
- if (_PyObject_LookupAttr(v, name, &x) != 0) {
+ if (PyObject_GetOptionalAttr(v, name, &x) != 0) {
return x;
}
/* Issue #17636: in case this failed because of a circular relative
diff --git a/Python/codecs.c b/Python/codecs.c
index f9f23005deb..4e47ff93a36 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -516,7 +516,7 @@ PyObject * _PyCodec_LookupTextEncoding(const char *encoding,
* attribute.
*/
if (!PyTuple_CheckExact(codec)) {
- if (_PyObject_LookupAttr(codec, &_Py_ID(_is_text_encoding), &attr) < 0) {
+ if (PyObject_GetOptionalAttr(codec, &_Py_ID(_is_text_encoding), &attr) < 0) {
Py_DECREF(codec);
return NULL;
}
diff --git a/Python/errors.c b/Python/errors.c
index b1a9858d82f..916958c9a0a 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -1748,7 +1748,7 @@ PyErr_SyntaxLocationObjectEx(PyObject *filename, int lineno, int col_offset,
}
}
if ((PyObject *)Py_TYPE(exc) != PyExc_SyntaxError) {
- if (_PyObject_LookupAttr(exc, &_Py_ID(msg), &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(exc, &_Py_ID(msg), &tmp) < 0) {
_PyErr_Clear(tstate);
}
else if (tmp) {
@@ -1767,7 +1767,7 @@ PyErr_SyntaxLocationObjectEx(PyObject *filename, int lineno, int col_offset,
}
}
- if (_PyObject_LookupAttr(exc, &_Py_ID(print_file_and_line), &tmp) < 0) {
+ if (PyObject_GetOptionalAttr(exc, &_Py_ID(print_file_and_line), &tmp) < 0) {
_PyErr_Clear(tstate);
}
else if (tmp) {
diff --git a/Python/import.c b/Python/import.c
index 7ce89cdf9a9..3e52a4e4eb1 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -2878,7 +2878,7 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
}
else {
PyObject *path;
- if (_PyObject_LookupAttr(mod, &_Py_ID(__path__), &path) < 0) {
+ if (PyObject_GetOptionalAttr(mod, &_Py_ID(__path__), &path) < 0) {
goto error;
}
if (path) {
diff --git a/Python/intrinsics.c b/Python/intrinsics.c
index 82f8cce7f92..037b74ca820 100644
--- a/Python/intrinsics.c
+++ b/Python/intrinsics.c
@@ -40,11 +40,11 @@ import_all_from(PyThreadState *tstate, PyObject *locals, PyObject *v)
int skip_leading_underscores = 0;
int pos, err;
- if (_PyObject_LookupAttr(v, &_Py_ID(__all__), &all) < 0) {
+ if (PyObject_GetOptionalAttr(v, &_Py_ID(__all__), &all) < 0) {
return -1; /* Unexpected error */
}
if (all == NULL) {
- if (_PyObject_LookupAttr(v, &_Py_ID(__dict__), &dict) < 0) {
+ if (PyObject_GetOptionalAttr(v, &_Py_ID(__dict__), &dict) < 0) {
return -1;
}
if (dict == NULL) {
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 60bf66c8a6b..721c527745c 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -953,7 +953,7 @@ print_exception_file_and_line(struct exception_print_context *ctx,
PyObject *f = ctx->file;
PyObject *tmp;
- int res = _PyObject_LookupAttr(*value_p, &_Py_ID(print_file_and_line), &tmp);
+ int res = PyObject_GetOptionalAttr(*value_p, &_Py_ID(print_file_and_line), &tmp);
if (res <= 0) {
if (res < 0) {
PyErr_Clear();
@@ -1132,7 +1132,7 @@ print_exception_notes(struct exception_print_context *ctx, PyObject *value)
}
PyObject *notes;
- int res = _PyObject_LookupAttr(value, &_Py_ID(__notes__), &notes);
+ int res = PyObject_GetOptionalAttr(value, &_Py_ID(__notes__), &notes);
if (res <= 0) {
return res;
}
diff --git a/Python/suggestions.c b/Python/suggestions.c
index ad58393490e..47aeb08180f 100644
--- a/Python/suggestions.c
+++ b/Python/suggestions.c
@@ -247,7 +247,7 @@ get_suggestions_for_name_error(PyObject* name, PyFrameObject* frame)
}
PyObject *value;
- res = _PyObject_LookupAttr(self, name, &value);
+ res = PyObject_GetOptionalAttr(self, name, &value);
Py_DECREF(locals);
if (res < 0) {
goto error;
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 0ac6edc5a16..fea3f61ee01 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -257,7 +257,7 @@ sys_audit_tstate(PyThreadState *ts, const char *event,
PyThreadState_EnterTracing(ts);
while ((hook = PyIter_Next(hooks)) != NULL) {
PyObject *o;
- int canTrace = _PyObject_LookupAttr(hook, &_Py_ID(__cantrace__), &o);
+ int canTrace = PyObject_GetOptionalAttr(hook, &_Py_ID(__cantrace__), &o);
if (o) {
canTrace = PyObject_IsTrue(o);
Py_DECREF(o);
@@ -657,7 +657,7 @@ sys_displayhook_unencodable(PyObject *outf, PyObject *o)
if (encoded == NULL)
goto error;
- if (_PyObject_LookupAttr(outf, &_Py_ID(buffer), &buffer) < 0) {
+ if (PyObject_GetOptionalAttr(outf, &_Py_ID(buffer), &buffer) < 0) {
Py_DECREF(encoded);
goto error;
}