Skip to content

Commit 981c124

Browse files
committed
fix implicit noexcept warnings
1 parent b4d154d commit 981c124

File tree

12 files changed

+40
-40
lines changed

12 files changed

+40
-40
lines changed

cypari2/closure.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ cdef extern from *:
100100

101101

102102
cdef GEN call_python(GEN arg1, GEN arg2, GEN arg3, GEN arg4, GEN arg5,
103-
ulong nargs, ulong py_func):
103+
ulong nargs, ulong py_func) noexcept:
104104
"""
105105
This function, which will be installed in PARI, is a front-end for
106106
``call_python_func_impl``.

cypari2/convert.pxd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cpdef gen_to_integer(Gen x)
2222

2323
# Conversion C -> PARI
2424

25-
cdef inline GEN double_to_REAL(double x):
25+
cdef inline GEN double_to_REAL(double x) noexcept:
2626
# PARI has an odd concept where it attempts to track the accuracy
2727
# of floating-point 0; a floating-point zero might be 0.0e-20
2828
# (meaning roughly that it might represent any number in the
@@ -42,7 +42,7 @@ cdef inline GEN double_to_REAL(double x):
4242
return dbltor(x)
4343

4444

45-
cdef inline GEN doubles_to_COMPLEX(double re, double im):
45+
cdef inline GEN doubles_to_COMPLEX(double re, double im) noexcept:
4646
cdef GEN g = cgetg(3, t_COMPLEX)
4747
if re == 0:
4848
set_gel(g, 1, gen_0)
@@ -57,15 +57,15 @@ cdef inline GEN doubles_to_COMPLEX(double re, double im):
5757

5858
# Conversion Python -> PARI
5959

60-
cdef inline GEN PyInt_AS_GEN(x):
60+
cdef inline GEN PyInt_AS_GEN(x) except? NULL:
6161
return stoi(PyInt_AS_LONG(x))
6262

63-
cdef GEN PyLong_AS_GEN(py_long x)
63+
cdef GEN PyLong_AS_GEN(py_long x) noexcept
6464

65-
cdef inline GEN PyFloat_AS_GEN(x):
65+
cdef inline GEN PyFloat_AS_GEN(x) except? NULL:
6666
return double_to_REAL(PyFloat_AS_DOUBLE(x))
6767

68-
cdef inline GEN PyComplex_AS_GEN(x):
68+
cdef inline GEN PyComplex_AS_GEN(x) except? NULL:
6969
return doubles_to_COMPLEX(
7070
PyComplex_RealAsDouble(x), PyComplex_ImagAsDouble(x))
7171

cypari2/convert.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ cdef PyLong_FromINT(GEN g):
455455
# Conversion Python -> PARI
456456
########################################################################
457457

458-
cdef GEN PyLong_AS_GEN(py_long x):
458+
cdef GEN PyLong_AS_GEN(py_long x) noexcept:
459459
cdef const digit* D = ob_digit(x)
460460

461461
# Size of the input

cypari2/gen.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ cdef class Gen(Gen_base):
2424
# memory allocated by gclone(). For constants, this is NULL.
2525
cdef GEN address
2626

27-
cdef inline pari_sp sp(self):
27+
cdef inline pari_sp sp(self) noexcept:
2828
return <pari_sp>self.address
2929

3030
# The Gen objects on the PARI stack form a linked list, from the

cypari2/gen.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ include 'auto_gen.pxi'
8181

8282

8383
cdef bint ellwp_flag1_bug = -1
84-
cdef inline bint have_ellwp_flag1_bug():
84+
cdef inline bint have_ellwp_flag1_bug() except -1:
8585
"""
8686
The PARI function ``ellwp(..., flag=1)`` has a bug in PARI versions
8787
2.9.x where the derivative is a factor 2 too small.

cypari2/handle_error.pxd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .types cimport GEN
22

3-
cdef void _pari_init_error_handling()
3+
cdef void _pari_init_error_handling() noexcept
44
cdef int _pari_err_handle(GEN E) except 0
5-
cdef void _pari_err_recover(long errnum)
5+
cdef void _pari_err_recover(long errnum) noexcept

cypari2/handle_error.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class PariError(RuntimeError):
126126
return self.errtext().rstrip(" .:")
127127

128128

129-
cdef void _pari_init_error_handling():
129+
cdef void _pari_init_error_handling() noexcept:
130130
"""
131131
Set up our code for handling PARI errors.
132132
@@ -211,7 +211,7 @@ cdef int _pari_err_handle(GEN E) except 0:
211211
raise PariError(errnum, pari_error_string, clone_gen_noclear(E))
212212

213213

214-
cdef void _pari_err_recover(long errnum):
214+
cdef void _pari_err_recover(long errnum) noexcept:
215215
"""
216216
Reset the error string and jump back to ``sig_on()``, either to
217217
retry the code (in case of no error) or to make the already-raised

cypari2/pari_instance.pxd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ cimport cython
33

44
from .gen cimport Gen
55

6-
cpdef long prec_bits_to_words(unsigned long prec_in_bits)
7-
cpdef long prec_words_to_bits(long prec_in_words)
8-
cpdef long default_bitprec()
6+
cpdef long prec_bits_to_words(unsigned long prec_in_bits) noexcept
7+
cpdef long prec_words_to_bits(long prec_in_words) noexcept
8+
cpdef long default_bitprec() noexcept
99

1010
cdef class Pari_auto:
1111
pass

cypari2/pari_instance.pyx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def prec_dec_to_bits(long prec_in_dec):
334334
return int(prec_in_dec*log_10 + 1.0) # Add one to round up
335335

336336

337-
cpdef long prec_bits_to_words(unsigned long prec_in_bits):
337+
cpdef long prec_bits_to_words(unsigned long prec_in_bits) noexcept:
338338
r"""
339339
Convert from precision expressed in bits to pari real precision
340340
expressed in words. Note: this rounds up to the nearest word,
@@ -362,7 +362,7 @@ cpdef long prec_bits_to_words(unsigned long prec_in_bits):
362362
return (prec_in_bits - 1)//wordsize + 3
363363

364364

365-
cpdef long prec_words_to_bits(long prec_in_words):
365+
cpdef long prec_words_to_bits(long prec_in_words) noexcept:
366366
r"""
367367
Convert from pari real precision expressed in words to precision
368368
expressed in bits. Note: this adjusts for the two codewords of a
@@ -385,7 +385,7 @@ cpdef long prec_words_to_bits(long prec_in_words):
385385
return (prec_in_words - 2) * BITS_IN_LONG
386386

387387

388-
cpdef long default_bitprec():
388+
cpdef long default_bitprec() noexcept:
389389
r"""
390390
Return the default precision in bits.
391391
@@ -446,7 +446,7 @@ def prec_words_to_dec(long prec_in_words):
446446
# of C library functions like puts().
447447
cdef PariOUT python_pariOut
448448

449-
cdef void python_putchar(char c):
449+
cdef void python_putchar(char c) noexcept:
450450
cdef char s[2]
451451
s[0] = c
452452
s[1] = 0
@@ -459,15 +459,15 @@ cdef void python_putchar(char c):
459459
# so it doesn't print one when an error occurs.
460460
pari_set_last_newline(1)
461461

462-
cdef void python_puts(const char* s):
462+
cdef void python_puts(const char* s) noexcept:
463463
try:
464464
# avoid string conversion if possible
465465
sys.stdout.buffer.write(s)
466466
except AttributeError:
467467
sys.stdout.write(to_string(s))
468468
pari_set_last_newline(1)
469469

470-
cdef void python_flush():
470+
cdef void python_flush() noexcept:
471471
sys.stdout.flush()
472472

473473
include 'auto_instance.pxi'
@@ -1436,22 +1436,22 @@ cdef long get_var(v) except -2:
14361436
# Monkey-patched versions of default(parisize) and default(parisizemax)
14371437
# which call before_resize() and after_resize().
14381438
# The monkey-patching is set up in PariInstance.__cinit__
1439-
cdef GEN patched_parisize(const char* v, long flag):
1440-
# Cast to int(*)() to avoid exception handling
1441-
if (<int(*)()>before_resize)():
1439+
cdef GEN patched_parisize(const char* v, long flag) noexcept:
1440+
# Cast to `int(*)() noexcept` to avoid exception handling
1441+
if (<int(*)() noexcept>before_resize)():
14421442
sig_error()
14431443
return sd_parisize(v, flag)
14441444

14451445

1446-
cdef GEN patched_parisizemax(const char* v, long flag):
1447-
# Cast to int(*)() to avoid exception handling
1448-
if (<int(*)()>before_resize)():
1446+
cdef GEN patched_parisizemax(const char* v, long flag) noexcept:
1447+
# Cast to `int(*)() noexcept` to avoid exception handling
1448+
if (<int(*)() noexcept>before_resize)():
14491449
sig_error()
14501450
return sd_parisizemax(v, flag)
14511451

14521452

14531453
IF HAVE_PLOT_SVG:
1454-
cdef void get_plot_ipython(PARI_plot* T):
1454+
cdef void get_plot_ipython(PARI_plot* T) noexcept:
14551455
# Values copied from src/graph/plotsvg.c in PARI sources
14561456
T.width = 480
14571457
T.height = 320
@@ -1462,7 +1462,7 @@ IF HAVE_PLOT_SVG:
14621462

14631463
T.draw = draw_ipython
14641464

1465-
cdef void draw_ipython(PARI_plot *T, GEN w, GEN x, GEN y):
1465+
cdef void draw_ipython(PARI_plot *T, GEN w, GEN x, GEN y) noexcept:
14661466
global avma
14671467
cdef pari_sp av = avma
14681468
cdef char* svg = rect2svg(w, x, y, T)

cypari2/paridecl.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5327,7 +5327,7 @@ cdef extern from *: # PARI headers already included by types.pxd
53275327

53285328

53295329
# Work around a bug in PARI's is_universal_constant()
5330-
cdef inline int is_universal_constant(GEN x):
5330+
cdef inline int is_universal_constant(GEN x) noexcept:
53315331
return _is_universal_constant(x) or (x is err_e_STACK)
53325332

53335333

0 commit comments

Comments
 (0)