From 679b58a6ee2bc9534cbd7ef8c507f46c10a6900c Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Wed, 26 May 2010 21:04:08 -0700 Subject: [PATCH] More large literal as double fixes. --- Cython/Compiler/ExprNodes.py | 5 +++-- Cython/Compiler/Nodes.py | 2 +- tests/run/literals.pyx | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 94172f2b..413a51f2 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -4993,8 +4993,9 @@ class NumBinopNode(BinopNode): return if self.type.is_complex: self.infix = False - self.operand1 = self.operand1.coerce_to(self.type, env) - self.operand2 = self.operand2.coerce_to(self.type, env) + if not self.infix or (type1.is_numeric and type2.is_numeric): + self.operand1 = self.operand1.coerce_to(self.type, env) + self.operand2 = self.operand2.coerce_to(self.type, env) def compute_c_result_type(self, type1, type2): if self.c_types_okay(type1, type2): diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index f1ee64a5..9b4fa4c2 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -3345,7 +3345,7 @@ class InPlaceAssignmentNode(AssignmentNode): import ExprNodes if self.lhs.type.is_pyobject: self.rhs = self.rhs.coerce_to_pyobject(env) - elif self.rhs.type.is_pyobject: + elif self.rhs.type.is_pyobject or (self.lhs.type.is_numeric and self.rhs.type.is_numeric): self.rhs = self.rhs.coerce_to(self.lhs.type, env) if self.lhs.type.is_pyobject: self.result_value_temp = ExprNodes.PyTempNode(self.pos, env) diff --git a/tests/run/literals.pyx b/tests/run/literals.pyx index 181dea63..388fe675 100644 --- a/tests/run/literals.pyx +++ b/tests/run/literals.pyx @@ -66,6 +66,8 @@ def test_complex(x): def test_large_int(double x): """ >>> test_large_int(0) - 1e+100 + 2e+100 """ - return x + 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + a = x + 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + a += 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + return a -- 2.26.2