From e49d3c7a7a9b117484bbe44353e2392f8004abc5 Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Thu, 14 May 2009 19:42:54 +0200 Subject: [PATCH] Fix obscure bug w/ complex (only present when compiling many files in one run) --- Cython/Compiler/PyrexTypes.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 17e4cf59..6cc6e511 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -718,6 +718,7 @@ class CComplexType(CNumericType): self.real_type = real_type CNumericType.__init__(self, real_type.rank + 0.5, real_type.signed) self.binops = {} + self.from_parts = "%s_from_parts" % self.specalization_name() def __cmp__(self, other): if isinstance(self, CComplexType) and isinstance(other, CComplexType): @@ -737,13 +738,13 @@ class CComplexType(CNumericType): or src_type is error_type) def create_declaration_utility_code(self, env): - if not hasattr(self, 'from_parts'): - self.from_parts = "%s_from_parts" % self.specalization_name() - env.use_utility_code(complex_generic_utility_code) - env.use_utility_code( - complex_arithmatic_utility_code.specialize(self, - math_h_modifier = self.real_type.math_h_modifier, - real_type = self.real_type.declaration_code(''))) + # This must always be run, because a single CComplexType instance can be shared + # across multiple compilations (the one created in the module scope) + env.use_utility_code(complex_generic_utility_code) + env.use_utility_code( + complex_arithmatic_utility_code.specialize(self, + math_h_modifier = self.real_type.math_h_modifier, + real_type = self.real_type.declaration_code(''))) return True def create_from_py_utility_code(self, env): -- 2.26.2