Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor delattrbehavior calls #225

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions atom/src/delattrbehavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Loading