From 968dc24925b61f162f2998a5f28b57e10bfdcf02 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Thu, 14 Mar 2019 13:59:53 -0400 Subject: [PATCH] [Python] Fix compatibility with Cython < 0.27 After setting the "language_level" directive (6c0866ef), nested comprehension expressions erroneously triggered an error message from the Cython compiler saying "local variable 's' referenced before assignment". While the problem has been fixed in Cython 0.27 and newer, this commit restores compatibility with older Cython versions as well. --- interfaces/cython/cantera/thermo.pyx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/interfaces/cython/cantera/thermo.pyx b/interfaces/cython/cantera/thermo.pyx index db3a78b33..e8a413f9f 100644 --- a/interfaces/cython/cantera/thermo.pyx +++ b/interfaces/cython/cantera/thermo.pyx @@ -659,9 +659,13 @@ cdef class ThermoPhase(_SolutionBase): >>> gas.get_equivalence_ratio(ignore=['NO']) 1.0 """ - if not oxidizers: # Default behavior, find all possible oxidizers - oxidizers = [s.name for s in self.species() if - all(y not in s.composition for y in ['C', 'H', 'S'])] + if not oxidizers: + # Default behavior, find all possible oxidizers + oxidizers = [] + for s in self.species(): + if all(y not in s.composition for y in ['C', 'H', 'S']): + oxidizers.append(s.name) + alpha = 0 mol_O = 0 for k, s in enumerate(self.species()):