Ticket #15118: trac15118.patch

File trac15118.patch, 1.8 KB (added by eviatarbach, 8 years ago)
  • sage/libs/mpmath/ext_impl.pxd

    # HG changeset patch
    # User Eviatar Bach <eviatarbach@gmail.com>
    # Date 1377704692 25200
    # Node ID 9ff104ad323f37114ba2cbd866ec9ab2b5613996
    # Parent  cee69e758af138e94a8b672a79f4e7724092285e
    Trac #15118: ZeroDivisionError in MPF_pow not propagated in Cython mpmath
    
    diff --git a/sage/libs/mpmath/ext_impl.pxd b/sage/libs/mpmath/ext_impl.pxd
    a b  
    6060cdef MPF_cos(MPF *c, MPF *x, MPopts opts)
    6161cdef MPF_sin(MPF *c, MPF *x, MPopts opts)
    6262cdef MPF_cos_sin(MPF *c, MPF *s, MPF *x, MPopts opts)
    63 cdef int MPF_pow(MPF *z, MPF *x, MPF *y, MPopts opts)
     63cdef int MPF_pow(MPF *z, MPF *x, MPF *y, MPopts opts) except -1
    6464cdef MPF_complex_pow(MPF *zre, MPF *zim, MPF *xre, MPF *xim, MPF *yre, MPF *yim, MPopts opts)
    6565cdef MPF_hypsum(MPF *a, MPF *b, int p, int q, param_types, str ztype, coeffs, \
    6666    z, long prec, long wp, long epsshift, dict magnitude_check, kwargs)
  • sage/libs/mpmath/ext_impl.pyx

    diff --git a/sage/libs/mpmath/ext_impl.pyx b/sage/libs/mpmath/ext_impl.pyx
    a b  
    11"""
    22This module provides the core implementation of multiprecision
    33floating-point arithmetic. Operations are done in-place.
     4
     5TESTS:
     6
     7See if :trac:`15118` is fixed::
     8
     9    sage: import mpmath
     10    sage: mpmath.mpf(0)^(-2)
     11    Traceback (most recent call last):
     12    ...
     13    ZeroDivisionError
     14    sage: mpmath.zeta(2r, -3r)
     15    Traceback (most recent call last):
     16    ...
     17    ZeroDivisionError
    418"""
    519
    620include 'sage/ext/interrupt.pxi'
     
    16461660    MPF_clear(&c)
    16471661    MPF_clear(&s)
    16481662
    1649 cdef int MPF_pow(MPF *z, MPF *x, MPF *y, MPopts opts):
     1663cdef int MPF_pow(MPF *z, MPF *x, MPF *y, MPopts opts) except -1:
    16501664    """
    16511665    Set z = x^y for real x and y and returns 0 if the result is real-valued.
    16521666    If the result is complex, does nothing and returns 1.