In the Cython wrapper definitions file gambit.pxd, not all functions are declared with except +. This means that if any of these functions does raise an exception, the result is an unhandled C++ exception which in general terminates the Python interpreter.
We mostly guard against this at the Cython level, but at the moment this does lead to problems in the case of invalid mixed strategy and behavior profiles, as in #389.
To do
The most straightforward solution is to wrap everything with except +, which at least will convert all exceptions to a generic Python RuntimeError exception.
Before doing so it might be worth taking a few minutes to understand whether there are any costs to doing this, as there are a number of functions which really ought never to throw an exception unless something is horribly wrong.
Overview
In the Cython wrapper definitions file
gambit.pxd
, not all functions are declared withexcept +
. This means that if any of these functions does raise an exception, the result is an unhandled C++ exception which in general terminates the Python interpreter.We mostly guard against this at the Cython level, but at the moment this does lead to problems in the case of invalid mixed strategy and behavior profiles, as in #389.
To do
The most straightforward solution is to wrap everything with
except +
, which at least will convert all exceptions to a generic PythonRuntimeError
exception.Before doing so it might be worth taking a few minutes to understand whether there are any costs to doing this, as there are a number of functions which really ought never to throw an exception unless something is horribly wrong.