package cython tags 641128 patch fixed-upstream thanks
Yaroslav, Ondřej, On Sat, Sep 10, 2011 at 01:54:55PM -0400, Yaroslav Halchenko wrote: > Hi Kirill, > > could you please check if this issue is present in current cython > version present in Debian unstable/testing 0.14.1 (or may be even recent > upstream release, 0.15 iirc) ? On Sat, Sep 10, 2011 at 02:52:52PM -0700, Ondřej Čertík wrote: > Hi Kirill! > > [snip] > > Thanks for reporting the bug. I verified, that it is present in > 0.14.1+, but in the latest git master (upstream) b1adce4, it works > again. So I assume it was already fixed upstream. Thanks for providing feedback. Yes, the bug is already fixed in upstream master, so I've bisected it and here are the results: The bug was first introduced in 0.11.rc-407-g3d2aa77 commit 3d2aa773bd79e1e5751de2ea2148696f52580f42 Author: Stefan Behnel <sco...@users.berlios.de> Date: Wed Jul 8 21:13:14 2009 +0200 fix __future__ division semantics for constant expressions and C integers --HG-- rename : tests/run/future_division.pyx => tests/run/non_future_division.pyx [...] + def find_compile_time_binary_operator(self, op1, op2): + func = compile_time_binary_operators[self.operator] + if self.operator == '/' and self.truedivision is None: + # => true div for floats, floor div for integers + if isinstance(op1, (int,long)) and isinstance(op2, (int,long)): + func = compile_time_binary_operators['//'] + return func + + def calculate_constant_result(self): + op1 = self.operand1.constant_result + op2 = self.operand2.constant_result + func = self.find_compile_time_binary_operator(op1, op2) + self.constant_result = func( + self.operand1.constant_result, + self.operand2.constant_result) + + def compile_time_value(self, denv): + operand1 = self.operand1.compile_time_value(denv) + operand2 = self.operand2.compile_time_value(denv) + try: + func = self.find_compile_time_binary_operator( + self, operand1, operand2) ^^^^ with erroneous extra `self`, and fixed in 0.14.1-111-g78e134e (unfortunately without tests): commit 78e134ede7646bacfaaafb71172fd4f86b890d0f Author: Robert Bradshaw <rober...@math.washington.edu> Date: Thu Mar 3 11:07:23 2011 -0800 Fix compile time division. diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index c965251..1fe8538 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -5992,7 +5992,7 @@ class DivNode(NumBinopNode): operand2 = self.operand2.compile_time_value(denv) try: func = self.find_compile_time_binary_operator( - self, operand1, operand2) + operand1, operand2) return func(operand1, operand2) except Exception, e: self.compile_time_value_error(e) which I think should be backported to Debian Cython packages. Thanks, Kirill P.S. > What exactly is "def degree = 1.0" supposed to do? I know what this does: > > cdef double degree = 1.0 > > But that is something different (I assume). It's a compile-time definition. From Pyrex manual [1]: """ Conditional Compilation ======================= Some features are available for conditional compilation and compile-time constants within a Pyrex source file. Compile-Time Definitions ------------------------ A compile-time constant can be defined using the DEF statement: DEF FavouriteFood = "spam" DEF ArraySize = 42 DEF OtherArraySize = 2 * ArraySize + 17 The right-hand side of the DEF must be a valid compile-time expression. Such expressions are made up of literal values and names defined using DEF statements, combined using any of the Python expression syntax. ... """ [1] http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/version/Doc/Manual/basics.html
>From 78e134ede7646bacfaaafb71172fd4f86b890d0f Mon Sep 17 00:00:00 2001 From: Robert Bradshaw <rober...@math.washington.edu> Date: Thu, 3 Mar 2011 11:07:23 -0800 Subject: [PATCH] Fix compile time division. --- Cython/Compiler/ExprNodes.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index c965251..1fe8538 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -5992,7 +5992,7 @@ class DivNode(NumBinopNode): operand2 = self.operand2.compile_time_value(denv) try: func = self.find_compile_time_binary_operator( - self, operand1, operand2) + operand1, operand2) return func(operand1, operand2) except Exception, e: self.compile_time_value_error(e) -- 1.7.7.rc1