From 2af6e7eef13ea5418623735fc175eff9d4a1342f Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Tue, 10 Jun 2014 00:17:41 +0200 Subject: [PATCH] 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. --- crlcore/src/pyCRL/PyCellGauge.cpp | 15 +++++++++++---- crlcore/src/pyCRL/PyRoutingGauge.cpp | 3 +-- hurricane/src/isobar/PyBox.cpp | 3 +-- hurricane/src/isobar/PyContact.cpp | 3 +-- hurricane/src/isobar/PyOccurrence.cpp | 19 +++++++++++-------- hurricane/src/isobar/PyRoutingPad.cpp | 3 +-- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/crlcore/src/pyCRL/PyCellGauge.cpp b/crlcore/src/pyCRL/PyCellGauge.cpp index 4895300e..d2a8f90e 100644 --- a/crlcore/src/pyCRL/PyCellGauge.cpp +++ b/crlcore/src/pyCRL/PyCellGauge.cpp @@ -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 */ }; diff --git a/crlcore/src/pyCRL/PyRoutingGauge.cpp b/crlcore/src/pyCRL/PyRoutingGauge.cpp index 590f46b7..c38f59df 100644 --- a/crlcore/src/pyCRL/PyRoutingGauge.cpp +++ b/crlcore/src/pyCRL/PyRoutingGauge.cpp @@ -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 | diff --git a/hurricane/src/isobar/PyBox.cpp b/hurricane/src/isobar/PyBox.cpp index 8dabcd35..75f6a591 100644 --- a/hurricane/src/isobar/PyBox.cpp +++ b/hurricane/src/isobar/PyBox.cpp @@ -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 | diff --git a/hurricane/src/isobar/PyContact.cpp b/hurricane/src/isobar/PyContact.cpp index e9d9d453..d67c919a 100644 --- a/hurricane/src/isobar/PyContact.cpp +++ b/hurricane/src/isobar/PyContact.cpp @@ -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 | diff --git a/hurricane/src/isobar/PyOccurrence.cpp b/hurricane/src/isobar/PyOccurrence.cpp index c7b8b327..04cdf908 100644 --- a/hurricane/src/isobar/PyOccurrence.cpp +++ b/hurricane/src/isobar/PyOccurrence.cpp @@ -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 diff --git a/hurricane/src/isobar/PyRoutingPad.cpp b/hurricane/src/isobar/PyRoutingPad.cpp index c1ddc1d1..054d3203 100644 --- a/hurricane/src/isobar/PyRoutingPad.cpp +++ b/hurricane/src/isobar/PyRoutingPad.cpp @@ -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 |