File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -972,6 +972,17 @@ static PyObject *CPy_GetCoro(PyObject *obj)
972
972
}
973
973
}
974
974
975
+ static PyObject * CPyObject_GetAttr3 (PyObject * v , PyObject * name , PyObject * defl )
976
+ {
977
+ PyObject * result = PyObject_GetAttr (v , name );
978
+ if (!result && PyErr_ExceptionMatches (PyExc_AttributeError )) {
979
+ PyErr_Clear ();
980
+ Py_INCREF (defl );
981
+ result = defl ;
982
+ }
983
+ return result ;
984
+ }
985
+
975
986
// mypy lets ints silently coerce to floats, so a mypyc runtime float
976
987
// might be an int also
977
988
static inline bool CPyFloat_Check (PyObject * o ) {
Original file line number Diff line number Diff line change 273
273
emit = call_emit ('PyObject_GetAttr' )
274
274
)
275
275
276
+ func_op (
277
+ name = 'builtins.getattr' ,
278
+ arg_types = [object_rprimitive , object_rprimitive , object_rprimitive ],
279
+ result_type = object_rprimitive ,
280
+ error_kind = ERR_MAGIC ,
281
+ emit = call_emit ('CPyObject_GetAttr3' )
282
+ )
283
+
276
284
py_setattr_op = func_op (
277
285
name = 'builtins.setattr' ,
278
286
arg_types = [object_rprimitive , object_rprimitive , object_rprimitive ],
You can’t perform that action at this time.
0 commit comments