Skip to content

Commit

Permalink
Make sure all setattr handler results get checked
Browse files Browse the repository at this point in the history
  • Loading branch information
frmdstryr authored and MatthieuDartiailh committed Jan 20, 2025
1 parent 19c081e commit bd7395f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions atom/src/setattrbehavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ call_object_object_value_handler( Member* member, CAtom* atom, PyObject* value )
if( !valueptr )
return -1;
PyObject* args[] = { pyobject_cast( atom ), valueptr.get() };
if( !PyObject_Vectorcall( member->setattr_context, args, 2, 0 ) )
cppy::ptr ok( PyObject_Vectorcall( member->setattr_context, args, 2, 0 ) );
if( !ok )
return -1;
return 0;
}
Expand All @@ -310,7 +311,8 @@ call_object_object_name_value_handler( Member* member, CAtom* atom, PyObject* va
if( !valueptr )
return -1;
PyObject* args[] = { pyobject_cast( atom ), member->name, valueptr.get() };
if( !PyObject_Vectorcall( member->setattr_context, args, 3, 0 ) )
cppy::ptr ok( PyObject_Vectorcall( member->setattr_context, args, 3, 0 ) );
if( !ok )
return -1;
return 0;
}
Expand All @@ -322,7 +324,8 @@ object_method_value_handler( Member* member, CAtom* atom, PyObject* value )
cppy::ptr valueptr( member->full_validate( atom, Py_None, value ) );
if( !valueptr )
return -1;
if( !PyObject_CallMethodOneArg( pyobject_cast( atom ), member->setattr_context, valueptr.get() ) )
cppy::ptr ok( PyObject_CallMethodOneArg( pyobject_cast( atom ), member->setattr_context, valueptr.get() ) );
if ( !ok )
return -1;
return 0;
}
Expand All @@ -335,7 +338,8 @@ object_method_name_value_handler( Member* member, CAtom* atom, PyObject* value )
if( !valueptr )
return -1;
PyObject* args[] = { pyobject_cast( atom ), member->name, valueptr.get() };
if( !PyObject_VectorcallMethod( member->setattr_context, args, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, 0 ) )
cppy::ptr ok( PyObject_VectorcallMethod( member->setattr_context, args, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, 0 ) );
if( !ok )
return -1;
return 0;
}
Expand All @@ -348,7 +352,8 @@ member_method_object_value_handler( Member* member, CAtom* atom, PyObject* value
if( !valueptr )
return -1;
PyObject* args[] = { pyobject_cast( member ), pyobject_cast( atom ), valueptr.get() };
if( !PyObject_VectorcallMethod( member->setattr_context, args, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, 0 ) )
cppy::ptr ok( PyObject_VectorcallMethod( member->setattr_context, args, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, 0 ) );
if( !ok )
return -1;
return 0;
}
Expand Down

0 comments on commit bd7395f

Please sign in to comment.