@@ -851,7 +851,7 @@ CDataType_from_param(PyObject *type, PyObject *value)
851851 return NULL ;
852852 }
853853
854- if (_PyObject_LookupAttr (value , & _Py_ID (_as_parameter_ ), & as_parameter ) < 0 ) {
854+ if (PyObject_GetOptionalAttr (value , & _Py_ID (_as_parameter_ ), & as_parameter ) < 0 ) {
855855 return NULL ;
856856 }
857857 if (as_parameter ) {
@@ -1495,7 +1495,7 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
14951495 stgdict = NULL ;
14961496 type_attr = NULL ;
14971497
1498- if (_PyObject_LookupAttr ((PyObject * )result , & _Py_ID (_length_ ), & length_attr ) < 0 ) {
1498+ if (PyObject_GetOptionalAttr ((PyObject * )result , & _Py_ID (_length_ ), & length_attr ) < 0 ) {
14991499 goto error ;
15001500 }
15011501 if (!length_attr ) {
@@ -1528,7 +1528,7 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
15281528 goto error ;
15291529 }
15301530
1531- if (_PyObject_LookupAttr ((PyObject * )result , & _Py_ID (_type_ ), & type_attr ) < 0 ) {
1531+ if (PyObject_GetOptionalAttr ((PyObject * )result , & _Py_ID (_type_ ), & type_attr ) < 0 ) {
15321532 goto error ;
15331533 }
15341534 if (!type_attr ) {
@@ -1720,7 +1720,7 @@ c_wchar_p_from_param(PyObject *type, PyObject *value)
17201720 }
17211721 }
17221722
1723- if (_PyObject_LookupAttr (value , & _Py_ID (_as_parameter_ ), & as_parameter ) < 0 ) {
1723+ if (PyObject_GetOptionalAttr (value , & _Py_ID (_as_parameter_ ), & as_parameter ) < 0 ) {
17241724 return NULL ;
17251725 }
17261726 if (as_parameter ) {
@@ -1784,7 +1784,7 @@ c_char_p_from_param(PyObject *type, PyObject *value)
17841784 }
17851785 }
17861786
1787- if (_PyObject_LookupAttr (value , & _Py_ID (_as_parameter_ ), & as_parameter ) < 0 ) {
1787+ if (PyObject_GetOptionalAttr (value , & _Py_ID (_as_parameter_ ), & as_parameter ) < 0 ) {
17881788 return NULL ;
17891789 }
17901790 if (as_parameter ) {
@@ -1919,7 +1919,7 @@ c_void_p_from_param(PyObject *type, PyObject *value)
19191919 }
19201920 }
19211921
1922- if (_PyObject_LookupAttr (value , & _Py_ID (_as_parameter_ ), & as_parameter ) < 0 ) {
1922+ if (PyObject_GetOptionalAttr (value , & _Py_ID (_as_parameter_ ), & as_parameter ) < 0 ) {
19231923 return NULL ;
19241924 }
19251925 if (as_parameter ) {
@@ -2054,7 +2054,7 @@ PyCSimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
20542054 if (result == NULL )
20552055 return NULL ;
20562056
2057- if (_PyObject_LookupAttr ((PyObject * )result , & _Py_ID (_type_ ), & proto ) < 0 ) {
2057+ if (PyObject_GetOptionalAttr ((PyObject * )result , & _Py_ID (_type_ ), & proto ) < 0 ) {
20582058 return NULL ;
20592059 }
20602060 if (!proto ) {
@@ -2266,7 +2266,7 @@ PyCSimpleType_from_param(PyObject *type, PyObject *value)
22662266 PyObject * exc = PyErr_GetRaisedException ();
22672267 Py_DECREF (parg );
22682268
2269- if (_PyObject_LookupAttr (value , & _Py_ID (_as_parameter_ ), & as_parameter ) < 0 ) {
2269+ if (PyObject_GetOptionalAttr (value , & _Py_ID (_as_parameter_ ), & as_parameter ) < 0 ) {
22702270 Py_XDECREF (exc );
22712271 return NULL ;
22722272 }
@@ -2429,7 +2429,7 @@ converters_from_argtypes(PyObject *ob)
24292429 }
24302430 */
24312431
2432- if (_PyObject_LookupAttr (tp , & _Py_ID (from_param ), & cnv ) <= 0 ) {
2432+ if (PyObject_GetOptionalAttr (tp , & _Py_ID (from_param ), & cnv ) <= 0 ) {
24332433 Py_DECREF (converters );
24342434 Py_DECREF (ob );
24352435 if (!PyErr_Occurred ()) {
@@ -2489,7 +2489,7 @@ make_funcptrtype_dict(StgDictObject *stgdict)
24892489 return -1 ;
24902490 }
24912491 stgdict -> restype = Py_NewRef (ob );
2492- if (_PyObject_LookupAttr (ob , & _Py_ID (_check_retval_ ),
2492+ if (PyObject_GetOptionalAttr (ob , & _Py_ID (_check_retval_ ),
24932493 & stgdict -> checker ) < 0 )
24942494 {
24952495 return -1 ;
@@ -3275,7 +3275,7 @@ PyCFuncPtr_set_restype(PyCFuncPtrObject *self, PyObject *ob, void *Py_UNUSED(ign
32753275 "restype must be a type, a callable, or None" );
32763276 return -1 ;
32773277 }
3278- if (_PyObject_LookupAttr (ob , & _Py_ID (_check_retval_ ), & checker ) < 0 ) {
3278+ if (PyObject_GetOptionalAttr (ob , & _Py_ID (_check_retval_ ), & checker ) < 0 ) {
32793279 return -1 ;
32803280 }
32813281 oldchecker = self -> checker ;
0 commit comments