Correct exception catching when creating invalid occurrence in Isobar.

* New: In CRL Core, in PyCellGauge, add the missing methods.
* Bug: In Isobar, PyOccurrence_create(), the HTRY/HCATCH block was not
    enclosing the constructor of Occurrence, which can throw exceptions.
    When an exception was thown the Python interpreter just terminate
    with the cryptic message:
      "Fatal Python error: Py_EndInterpreter: thread still has a frame"
    Reminder to myself: when such a message occurs, it means that the
    interpreter did encounter a problem, but it's related to the isobar
    interface.
This commit is contained in:
Jean-Paul Chaput 2014-06-10 00:17:41 +02:00
parent da5fb18971
commit 2af6e7eef1
6 changed files with 26 additions and 20 deletions

View File

@ -1,8 +1,7 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2012-2012, All Rights Reserved
// Copyright (c) UPMC/LIP6 2012-2014, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
@ -54,6 +53,11 @@ extern "C" {
// +=================================================================+
DirectGetLongAttribute(PyCellGauge_getSliceHeight,getSliceHeight,PyCellGauge,CellGauge)
DirectGetLongAttribute(PyCellGauge_getSliceStep ,getSliceStep ,PyCellGauge,CellGauge)
DirectGetLongAttribute(PyCellGauge_getPitch ,getPitch ,PyCellGauge,CellGauge)
static PyObject* PyCellGauge_create ( PyObject*, PyObject* args )
{
trace << "PyCellGauge_create()" << endl;
@ -104,9 +108,12 @@ extern "C" {
PyMethodDef PyCellGauge_Methods[] =
{ { "create" , (PyCFunction)PyCellGauge_create , METH_VARARGS|METH_STATIC
{ { "create" , (PyCFunction)PyCellGauge_create , METH_VARARGS|METH_STATIC
, "Create a new CellGauge." }
//, { "destroy" , (PyCFunction)PyCellGauge_destroy , METH_VARARGS
, { "getSliceHeight" , (PyCFunction)PyCellGauge_getSliceHeight, METH_NOARGS , "Return the slice height." }
, { "getSliceStep" , (PyCFunction)PyCellGauge_getSliceStep , METH_NOARGS , "Return the slice step." }
, { "getPitch" , (PyCFunction)PyCellGauge_getPitch , METH_NOARGS , "Return the smallest common pitch." }
//, { "destroy" , (PyCFunction)PyCellGauge_destroy , METH_VARARGS
// , "Destroy the associated hurricane object. The python object remains." }
, {NULL, NULL, 0, NULL} /* sentinel */
};

View File

@ -1,8 +1,7 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2012-2012, All Rights Reserved
// Copyright (c) UPMC/LIP6 2012-2014, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |

View File

@ -1,8 +1,7 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2008-2013, All Rights Reserved
// Copyright (c) UPMC 2008-2014, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |

View File

@ -1,8 +1,7 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2008-2013, All Rights Reserved
// Copyright (c) UPMC 2008-2014, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |

View File

@ -1,5 +1,9 @@
// x-----------------------------------------------------------------x
// | |
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2013-2014, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | I s o b a r - Hurricane / Python Interface |
// | |
@ -7,10 +11,8 @@
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== |
// | C++ Module : "./PyOccurrence.cpp" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
// +-----------------------------------------------------------------+
#include "hurricane/isobar/PyBox.h"
#include "hurricane/isobar/PyTransformation.h"
@ -222,6 +224,8 @@ extern "C" {
return NULL;
}
PyOccurrence* pyOccurrence = NULL;
HTRY
if ( __cs.getObjectIds() == NO_ARG ) { occurrence = new Occurrence (); }
else if ( __cs.getObjectIds() == ENT_ARG ) { occurrence = new Occurrence ( PYENTITY_O(arg0) ); }
else if ( __cs.getObjectIds() == COMP_PATH_ARG) { occurrence = new Occurrence ( PYSEGMENT_O(arg0)
@ -233,10 +237,9 @@ extern "C" {
return ( NULL );
}
PyOccurrence* pyOccurrence = PyObject_NEW(PyOccurrence, &PyTypeOccurrence);
pyOccurrence = PyObject_NEW(PyOccurrence, &PyTypeOccurrence);
if (pyOccurrence == NULL) return NULL;
HTRY
pyOccurrence->_object = occurrence;
HCATCH

View File

@ -1,8 +1,7 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2013-2013, All Rights Reserved
// Copyright (c) UPMC 2013-2014, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |