From a05834c741dd7c5ec9e944633c8418adc45295b7 Mon Sep 17 00:00:00 2001 From: frmdstryr Date: Sat, 18 Jan 2025 12:49:49 -0500 Subject: [PATCH] Refactor delattrbehavior calls --- atom/src/delattrbehavior.cpp | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/atom/src/delattrbehavior.cpp b/atom/src/delattrbehavior.cpp index c479c6a7..63607d81 100644 --- a/atom/src/delattrbehavior.cpp +++ b/atom/src/delattrbehavior.cpp @@ -155,17 +155,7 @@ _mangled_property_handler( Member* member, CAtom* atom ) cppy::ptr name( PyUnicode_FromFormat( "_del_%s", suffix ) ); if( !name ) return -1; - cppy::ptr callable( PyObject_GetAttr( pyobject_cast( atom ), name.get() ) ); - if( !callable ) - { - if( PyErr_ExceptionMatches( PyExc_AttributeError ) ) - PyErr_SetString( PyExc_AttributeError, "can't delete attribute" ); - return -1; - } - cppy::ptr args( PyTuple_New( 0 ) ); - if( !args ) - return -1; - cppy::ptr ok( callable.call( args ) ); + cppy::ptr ok( PyObject_CallMethodNoArgs( pyobject_cast( atom ), name.get() ) ); if( !ok ) return -1; return 0; @@ -177,11 +167,7 @@ property_handler( Member* member, CAtom* atom ) { if( member->delattr_context != Py_None ) { - cppy::ptr args( PyTuple_New( 1 ) ); - if( !args ) - return -1; - PyTuple_SET_ITEM( args.get(), 0, cppy::incref( pyobject_cast( atom ) ) ); - cppy::ptr ok( PyObject_Call( member->delattr_context, args.get(), 0 ) ); + cppy::ptr ok( PyObject_CallOneArg( member->delattr_context, pyobject_cast( atom ) ) ); if( !ok ) return -1; return 0;