Ticket #9826: sage-trac_9826-typofix.patch

File sage-trac_9826-typofix.patch, 1.6 KB (added by mjo, 10 years ago)

Same patch with my typo fixed.

  • sage/rings/polynomial/polynomial_real_mpfr_dense.pyx

    # HG changeset patch
    # User Michael Orlitzky <michael@orlitzky.com>
    # Date 1325513485 18000
    # Node ID 1eef4fd95d93d916464e3bf7521d13161ae803b1
    # Parent  066e670b78c3a890b14e7700ed379684df270b7d
    Don't clean up uninitialized coefficients (#9826)
    
    diff --git a/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx b/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx
    a b  
    6767            ... except KeyboardInterrupt:
    6868            ...     print "ok"
    6969            ok
     70
     71        Test that we don't clean up uninitialized coefficients (#9826)::
     72
     73            sage: k.<a> = GF(7^3)
     74            sage: P.<x> = PolynomialRing(k)
     75            sage: (a*x).complex_roots()
     76            Traceback (most recent call last):
     77            ...
     78            TypeError: Unable to convert x (='a') to real number.
     79
    7080        """
    7181        Polynomial.__init__(self, parent, is_gen=is_gen)
    7282        self._base_ring = parent._base
     
    101111                sig_off()
    102112
    103113        sig_on()
    104         degree = self._degree = len(x) - 1
     114        degree = len(x) - 1
     115        self._degree = -1
    105116        cdef mpfr_t* coeffs
    106117        coeffs = <mpfr_t*>sage_malloc(sizeof(mpfr_t)*(degree+1))
    107118        try:  # We might get Python exceptions here
    108119            for i from 0 <= i <= degree:
    109120                mpfr_init2(coeffs[i], prec)
     121                self._degree += 1
    110122                a = x[i]
    111123                if PY_TYPE_CHECK_EXACT(a, RealNumber):
    112124                    mpfr_set(coeffs[i], (<RealNumber>a).value, rnd)