Skip to content

Commit 69f5162

Browse files
authored
gh-148119: Refactor get_type_attr_as_size to improve error handling in structseq.c (#148120)
1 parent 1795fcc commit 69f5162

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Objects/structseq.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ static Py_ssize_t
2828
get_type_attr_as_size(PyTypeObject *tp, PyObject *name)
2929
{
3030
PyObject *v = PyDict_GetItemWithError(_PyType_GetDict(tp), name);
31-
if (v == NULL && !PyErr_Occurred()) {
31+
32+
if (v == NULL) {
33+
if (PyErr_Occurred()) {
34+
return -1;
35+
}
3236
PyErr_Format(PyExc_TypeError,
3337
"Missed attribute '%U' of type %s",
3438
name, tp->tp_name);

0 commit comments

Comments
 (0)