https://github.com/python/cpython/commit/69f51625e6314883456b336b9e3471a6221d2787
commit: 69f51625e6314883456b336b9e3471a6221d2787
branch: main
author: Wulian233 <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2026-04-06T17:41:30+05:30
summary:

gh-148119: Refactor `get_type_attr_as_size` to improve error handling in 
`structseq.c` (#148120)

files:
M Objects/structseq.c

diff --git a/Objects/structseq.c b/Objects/structseq.c
index 8fa9cbba3bcce3..9130fe6a133b1e 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -28,7 +28,11 @@ static Py_ssize_t
 get_type_attr_as_size(PyTypeObject *tp, PyObject *name)
 {
     PyObject *v = PyDict_GetItemWithError(_PyType_GetDict(tp), name);
-    if (v == NULL && !PyErr_Occurred()) {
+
+    if (v == NULL) {
+        if (PyErr_Occurred()) {
+            return -1;
+        }
         PyErr_Format(PyExc_TypeError,
                      "Missed attribute '%U' of type %s",
                      name, tp->tp_name);

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to