Skip to content

Commit 462318e

Browse files
committed
ensure self is not zero
1 parent e0312f8 commit 462318e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/flint/types/nmod_poly.pyx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,10 @@ cdef class nmod_poly(flint_poly):
260260
45*x^4 + 23*x^3 + 159*x^2 + 151*x + 110
261261
"""
262262
if n <= 0:
263-
raise ValueError("n must be positive")
263+
raise ValueError(f"{n = } must be positive")
264+
265+
if self.is_zero():
266+
raise ValueError(f"cannot invert the zero element")
264267

265268
cdef nmod_poly res
266269
res = nmod_poly.__new__(nmod_poly)

0 commit comments

Comments
 (0)