Commit
2 years ago
gh-36422: replace wrongly placed sig_on/off pair with sig_check fixes the bug noted in https://github.com/mpmath/mpmath/issues/723 The problem comes from the `sig_on/off` pair guarding non-Cython statements; we replace it by `sig_check()` ``` sage: from mpmath import * sage: mp.dps=16 sage: zeta(-0.01 + 1000j) ------------------------------------------------------------------------ --- SystemError Traceback (most recent call last) Cell In [3], line 1 ----> 1 zeta(-RealNumber('0.01') + ComplexNumber(0, '1000')) File /usr/lib/python3.11/site-packages/mpmath/functions/zeta.py:580, in zeta(ctx, s, a, derivative, method, **kwargs) 578 if ctx.re(s) > 2*ctx.prec and a == 1 and not derivative: 579 return ctx.one + ctx.power(2, -s) --> 580 return +ctx._hurwitz(s, a, d, **kwargs) File /usr/lib/python3.11/site-packages/mpmath/functions/zeta.py:595, in _hurwitz(ctx, s, a, d, **kwargs) 593 print("zeta: Attempting reflection formula") 594 try: --> 595 return _hurwitz_reflection(ctx, s, a, d, atype) 596 except NotImplementedError: 597 pass File /usr/lib/python3.11/site-packages/mpmath/functions/zeta.py:654, in _hurwitz_reflection(ctx, s, a, d, atype) 652 p += shift*q 653 assert 1 <= p <= q --> 654 g = ctx.fsum(ctx.cospi(t/2-2*k*b)*ctx._hurwitz(t,(k,q)) \ 655 for k in range(1,q+1)) 656 g *= 2*ctx.gamma(t)/(2*ctx.pi*q)**t 657 v += g File /mnt/opt/Sage/sage-dev/src/sage/libs/mpmath/ext_main.pyx:767, in sage.libs.mpmath.ext_main.Context.fsum() 765 workopts.rounding = ROUND_D 766 unknown = global_context.zero --> 767 sig_on() 768 try: # Way down, there is a ``finally`` with sig_off() 769 MPF_init(&sre) SystemError: calling remove_from_pari_stack() inside sig_on() ``` URL: https://github.com/sagemath/sage/pull/36422 Reported by: Dima Pasechnik Reviewer(s): Dima Pasechnik, Kwankyu Lee
Author
Release Manager
Loading