Ticket #11885: trac_11885_v2.patch

File trac_11885_v2.patch, 1.0 KB (added by benjaminfjones, 11 years ago)

adds an exception check in call()

  • sage/libs/mpmath/utils.pyx

    # HG changeset patch
    # User Benjamin Jones <benjaminfjones@gmail.com>
    # Date 1317408128 18000
    # Node ID fb5d9ee43142c5fba6351abfbeefa6c9194c7396
    # Parent  b1a099f40be3f25088294fdcb19612508d97b404
    Trac 11885: added check that parent has attribute 'prec' before calling it
    
    diff --git a/sage/libs/mpmath/utils.pyx b/sage/libs/mpmath/utils.pyx
    a b  
    406406        sage: type(_)
    407407        <type 'sage.rings.real_double.RealDoubleElement'>
    408408
     409    Check that Trac 11885 is fixed::
     410
     411        sage: a.call(a.ei, 1.0r, parent=float)
     412        1.8951178163559366
     413
    409414    """
    410415    from mpmath import mp
    411416    orig = mp.prec
    412417    prec = kwargs.pop('prec', orig)
    413418    parent = kwargs.pop('parent', None)
    414419    if parent is not None:
    415         prec = parent.prec()
     420        try:
     421            prec = parent.prec()
     422        except AttributeError:
     423            pass
    416424    prec2 = prec + 20
    417425    args = sage_to_mpmath(args, prec2)
    418426    kwargs = sage_to_mpmath(kwargs, prec2)