From 99b3e7ea1b6578ba9f93cf546cd8e76abbdbef6c Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 14 Oct 2015 12:58:08 -0400 Subject: [PATCH] [Python] Fix handling of bad input to 'stringify' Cases where a string is required but a non-string is provided will now generate an exception instead of substituting the empty string. --- interfaces/cython/cantera/_cantera.pxd | 2 +- interfaces/cython/cantera/utils.pyx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index 78d83b15e..7d665ad0f 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -977,7 +977,7 @@ cdef class ReactionPathDiagram: cdef CxxStringStream* _log # free functions -cdef string stringify(x) +cdef string stringify(x) except * cdef pystr(string x) cdef np.ndarray get_species_array(Kinetics kin, kineticsMethod1d method) cdef np.ndarray get_reaction_array(Kinetics kin, kineticsMethod1d method) diff --git a/interfaces/cython/cantera/utils.pyx b/interfaces/cython/cantera/utils.pyx index 23b3788a3..906aa19c5 100644 --- a/interfaces/cython/cantera/utils.pyx +++ b/interfaces/cython/cantera/utils.pyx @@ -4,7 +4,7 @@ cdef int _pythonMajorVersion = sys.version_info[0] cdef CxxPythonLogger* _logger = new CxxPythonLogger() CxxSetLogger(_logger) -cdef string stringify(x): +cdef string stringify(x) except *: """ Converts Python strings to std::string. """ # This method works with both Python 2.x and 3.x. if isinstance(x, bytes):