More explicit error message in EtesianEngine.setBlock() Python wrapper.

This commit is contained in:
Jean-Paul Chaput 2020-10-14 15:08:26 +02:00
parent 51c6b90160
commit 0a5fbd9ff0
1 changed files with 8 additions and 3 deletions

View File

@ -48,10 +48,12 @@ namespace Etesian {
using Isobar::getPyHash;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::EntityCast;
using Isobar::PyCell;
using Isobar::PyCell_Link;
using Isobar::PyInstance;
using Isobar::PyInstance_Link;
using Isobar::PyTypeInstance;
using Isobar::PyCellViewer;
using Isobar::PyTypeCellViewer;
using CRL::PyToolEngine;
@ -165,12 +167,15 @@ extern "C" {
cdebug_log(34,0) << "PyEtesianEngine_setBlock()" << endl;
HTRY
METHOD_HEAD ( "EtesianEngine.setBlock()" )
PyInstance* pyInstance = NULL;
if (not ParseOneArg("EtesianEngine.setBlock",args,INST_ARG,(PyObject**)&pyInstance) )
return NULL;
etesian->setBlock( PYINSTANCE_O(pyInstance) );
Instance* instance = dynamic_cast<Instance*>( EntityCast((PyObject*)pyInstance) );
if (not instance) {
PyErr_SetString( ConstructorError, "EtesianEngine.setBlock(): Parameter is not an Instance." );
return NULL;
}
etesian->setBlock( instance );
HCATCH
Py_RETURN_NONE;
}