# HG changeset patch
# User Robert Bradshaw <robertwb@math.washington.edu>
# Date 1314767776 25200
# Node ID 8c8c6740b23f218520d3db550e2994ab1679807d
# Parent  2a2abbcad325ccca9399981ceddf5897eb467e64
#11761 - Upgrade to Cython 0.15

Most of these changes are due to the fact that Cython no longer initializes
all locals to None, rather using such a variable is an error as it is in
Python.

diff -r 2a2abbcad325 -r 8c8c6740b23f sage/coding/binary_code.pyx
--- a/sage/coding/binary_code.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/coding/binary_code.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -1516,7 +1516,7 @@
     """
     def __cinit__(self, arg1, arg2=None):
         cdef int k, nwords, ncols, sizeof_int
-        cdef PartitionStack other
+        cdef PartitionStack other = None
         cdef int *wd_ents, *wd_lvls, *col_ents, *col_lvls
         cdef int *col_degs, *col_counts, *col_output, *wd_degs, *wd_counts, *wd_output
         sizeof_int = sizeof(int)
diff -r 2a2abbcad325 -r 8c8c6740b23f sage/libs/singular/function.pyx
--- a/sage/libs/singular/function.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/libs/singular/function.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -1102,6 +1102,7 @@
         """
         from  sage.matrix.matrix_mpolynomial_dense import Matrix_mpolynomial_dense
         from sage.matrix.matrix_integer_dense import Matrix_integer_dense
+        ring2 = None
         for a in args:
             if PY_TYPE_CHECK(a, MPolynomialIdeal):
                 ring2 = a.ring()
diff -r 2a2abbcad325 -r 8c8c6740b23f sage/matrix/matrix_dense.pyx
--- a/sage/matrix/matrix_dense.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/matrix/matrix_dense.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -397,7 +397,7 @@
             image.subdivide(*self.subdivisions())
         return image
 
-    def _derivative(self, var=None):
+    def _derivative(self, var=None, R=None):
         """
         Differentiate with respect to var by differentiating each element
         with respect to var.
diff -r 2a2abbcad325 -r 8c8c6740b23f sage/matrix/matrix_double_dense.pyx
--- a/sage/matrix/matrix_double_dense.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/matrix/matrix_double_dense.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -1960,7 +1960,8 @@
         """
         if algorithm not in ('pade', 'eig', 'taylor'):
             raise ValueError("algorithm must be 'pade', 'eig', or 'taylor'")
-            
+
+        global scipy
         if scipy is None:
             import scipy
         import scipy.linalg
diff -r 2a2abbcad325 -r 8c8c6740b23f sage/matrix/matrix_integer_dense.pyx
--- a/sage/matrix/matrix_integer_dense.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/matrix/matrix_integer_dense.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -1659,6 +1659,7 @@
 
         proof = get_proof_flag(proof, "linear_algebra")
         pivots = None
+        rank = None
 
         if algorithm == "padic":
             import matrix_integer_dense_hnf
diff -r 2a2abbcad325 -r 8c8c6740b23f sage/matrix/matrix_sparse.pyx
--- a/sage/matrix/matrix_sparse.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/matrix/matrix_sparse.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -656,7 +656,7 @@
             m.subdivide(*self.subdivisions())
         return m
 
-    def _derivative(self, var=None):
+    def _derivative(self, var=None, R=None):
         """
         Differentiate with respect to var by differentiating each element
         with respect to var.
diff -r 2a2abbcad325 -r 8c8c6740b23f sage/matrix/misc.pyx
--- a/sage/matrix/misc.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/matrix/misc.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -327,6 +327,7 @@
         p = matrix_modn_sparse.MAX_MODULUS + 1
     else:
         p = matrix_modn_dense.MAX_MODULUS + 1
+    t = None
     X = []
     best_pivots = []        
     prod = 1
diff -r 2a2abbcad325 -r 8c8c6740b23f sage/misc/misc_c.pyx
--- a/sage/misc/misc_c.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/misc/misc_c.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -42,6 +42,7 @@
         [101, 103, 106, 110, 115, 121, 128, 136, 145, 155]
     """
     cdef bint first = 1
+    running = None
     for x in L:
         if first:
             total = L[0] if start is None else L[0]+start
diff -r 2a2abbcad325 -r 8c8c6740b23f sage/plot/plot3d/base.pyx
--- a/sage/plot/plot3d/base.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/plot/plot3d/base.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -906,9 +906,9 @@
             from shapes2 import frame3d, frame_labels
             F = frame3d(xyz_min, xyz_max, opacity=0.5, color=(0,0,0), thickness=thickness)
             if labels:
-                F_text = frame_labels(xyz_min, xyz_max, a_min_orig, a_max_orig)
-
-            X += F + F_text
+                F += frame_labels(xyz_min, xyz_max, a_min_orig, a_max_orig)
+            
+            X += F
 
         if axes:
             # draw axes
diff -r 2a2abbcad325 -r 8c8c6740b23f sage/rings/fraction_field_element.pyx
--- a/sage/rings/fraction_field_element.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/rings/fraction_field_element.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -206,11 +206,11 @@
                     pass
             self.__numerator   = num
             self.__denominator = den
-        except AttributeError, s:
+        except AttributeError:
             raise ArithmeticError, "unable to reduce because lack of gcd or quo_rem algorithm"
-        except TypeError, s:
+        except TypeError:
             raise ArithmeticError, "unable to reduce because gcd algorithm doesn't work on input"
-        except NotImplementedError, s:
+        except NotImplementedError:
             raise ArithmeticError, "unable to reduce because gcd algorithm not implemented on input"            
 
     def __copy__(self):
diff -r 2a2abbcad325 -r 8c8c6740b23f sage/rings/integer.pyx
--- a/sage/rings/integer.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/rings/integer.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -4107,7 +4107,7 @@
         #    raise RuntimeError, "inconsistent results between GMP and pari"
         #return g.isprime(flag=flag)
 
-    def is_prime(self):
+    def is_prime(self, proof=None):
         r"""
         Returns ``True`` if self is prime.
         
diff -r 2a2abbcad325 -r 8c8c6740b23f sage/rings/polynomial/pbori.pyx
--- a/sage/rings/polynomial/pbori.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/rings/polynomial/pbori.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -625,6 +625,7 @@
             sage: I.groebner_basis()
             [1]
         """
+        msg = None
         cdef BooleanPolynomial p
         # we check for other PolyBoRi types first since this conversion
         # is used by the PolyBoRi python code often
@@ -653,7 +654,7 @@
                     p *= var_mapping[i]
                 return p
             else:
-                raise TypeError, "cannot coerce monomial %s to %s: %s"%(other,self,msg)
+                raise TypeError, "cannot coerce monomial %s to %s"%(other,self)
 
         elif PY_TYPE_CHECK(other,BooleanPolynomial) and \
             ((<BooleanPolynomialRing>(<BooleanPolynomial>other)\
@@ -749,6 +750,7 @@
             ...
             TypeError: cannot convert polynomial z*x^2 + 5*y^3 to Boolean PolynomialRing in x, y: name z not defined
         """
+        msg = None
         cdef int i
 
         try:
@@ -1941,7 +1943,7 @@
                             m*= var_mapping[i]
                         return m
                 else:
-                    raise ValueError, "cannot convert polynomial %s to %s: %s"%(other,self,msg)
+                    raise ValueError, "cannot convert polynomial %s to %s"%(other,self)
 
         elif PY_TYPE_CHECK(other, BooleanMonomial) and \
             ((<BooleanMonomial>other)._pbmonom.deg() <= \
diff -r 2a2abbcad325 -r 8c8c6740b23f sage/rings/real_double.pyx
--- a/sage/rings/real_double.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/rings/real_double.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -1674,7 +1674,7 @@
                 return exponent.parent()(self) ** exponent # neither operand is RealDoubleElement
         else:
             try:
-                base = exp.parent()(self)
+                base = exponent.parent()(self)
                 return base.__pow_float((<RealDoubleElement>exponent)._value)
             except TypeError:
                 return self ** self.parent()(exponent) # neither operand is RealDoubleElement
diff -r 2a2abbcad325 -r 8c8c6740b23f sage/rings/real_mpfi.pyx
--- a/sage/rings/real_mpfi.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/rings/real_mpfi.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -999,10 +999,10 @@
             mpfi_set_fr(self.value, rn.value)
         elif PY_TYPE_CHECK(x, Rational):
             rat = x
-            mpfi_set_q(self.value, <mpq_t> rat.value)
+            mpfi_set_q(self.value, rat.value)
         elif PY_TYPE_CHECK(x, Integer):
             integ = x
-            mpfi_set_z(self.value, <mpz_t> integ.value)
+            mpfi_set_z(self.value, integ.value)
         elif PY_TYPE_CHECK(x, int):
             ix = x
             mpfi_set_si(self.value, ix)
diff -r 2a2abbcad325 -r 8c8c6740b23f sage/structure/coerce.pyx
--- a/sage/structure/coerce.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/structure/coerce.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -514,6 +514,7 @@
             2
             """
         self._exceptions_cleared = False
+        res = None
         if not PY_TYPE_CHECK(xp, type) and not PY_TYPE_CHECK(xp, Parent):
             xp = parent_c(xp)
         if not PY_TYPE_CHECK(yp, type) and not PY_TYPE_CHECK(yp, Parent):
@@ -710,6 +711,7 @@
                 return (<Action>action)._call_(x, y)
         
         try:
+            xy = None
             xy = self.canonical_coercion(x,y)
             return PyObject_CallObject(op, xy)
         except TypeError, err:
diff -r 2a2abbcad325 -r 8c8c6740b23f sage/symbolic/expression.pyx
--- a/sage/symbolic/expression.pyx	Thu Aug 11 12:52:48 2011 +0000
+++ b/sage/symbolic/expression.pyx	Tue Aug 30 22:16:16 2011 -0700
@@ -1956,8 +1956,8 @@
             falsify = operator.lt
         cdef bint equality_ok = op in [equal, less_or_equal, greater_or_equal]
         cdef int errors = 0
+        val = None
         if len(vars) == 0:
-            val = None
             try:
                 val = domain(diff)
             except (TypeError, ValueError, ArithmeticError), ex:
@@ -2563,7 +2563,7 @@
             sage: x^oo
             Traceback (most recent call last):
             ...
-            RuntimeError: power::eval(): pow(x, Infinity) for non numeric x is not defined.
+            ValueError: power::eval(): pow(x, Infinity) for non numeric x is not defined.
             sage: SR(oo)^2
             +Infinity
             sage: SR(-oo)^2
@@ -3453,11 +3453,11 @@
             sage: (x^y).subs(x=oo)
             Traceback (most recent call last):
             ...
-            RuntimeError: power::eval(): pow(Infinity, x) for non numeric x is not defined.
+            ValueError: power::eval(): pow(Infinity, x) for non numeric x is not defined.
             sage: (x^y).subs(y=oo)
             Traceback (most recent call last):
             ...
-            RuntimeError: power::eval(): pow(x, Infinity) for non numeric x is not defined.
+            ValueError: power::eval(): pow(x, Infinity) for non numeric x is not defined.
             sage: (x+y).subs(x=oo)
             +Infinity
             sage: (x-y).subs(y=oo)
diff -r 2a2abbcad325 -r 8c8c6740b23f setup.py
--- a/setup.py	Thu Aug 11 12:52:48 2011 +0000
+++ b/setup.py	Tue Aug 30 22:16:16 2011 -0700
@@ -805,7 +805,7 @@
             cplus = ''
 
         # call cython, abort if it failed
-        cmd = "python `which cython` %s --disable-function-redefinition --embed-positions --directive cdivision=True,autotestdict=False,fast_getattr=True -I%s -o %s %s"%(cplus, os.getcwd(), outfile, f)
+        cmd = "python `which cython` %s --old-style-globals --disable-function-redefinition --embed-positions --directive cdivision=True,autotestdict=False,fast_getattr=True -I%s -o %s %s"%(cplus, os.getcwd(), outfile, f)
         r = run_command(cmd)
         if r:
             return r
