Skip to content

Commit ada4b2f

Browse files
committed
Raise exception on parsing failure
1 parent 4bef177 commit ada4b2f

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/flint/types/fmpq_mpoly.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ cdef class fmpq_mpoly(flint_mpoly):
230230
raise ValueError("Cannot parse a polynomial without context")
231231
val = val.encode("ascii")
232232
init_fmpq_mpoly(self, ctx)
233-
fmpq_mpoly_set_str_pretty(self.val, val, self.ctx.c_names, self.ctx.val)
233+
if fmpq_mpoly_set_str_pretty(self.val, val, self.ctx.c_names, self.ctx.val) == -1:
234+
raise ValueError("Unable to parse fmpq_mpoly from string")
234235
fmpq_mpoly_sort_terms(self.val, self.ctx.val)
235236
else:
236237
v = any_as_fmpq(val)

src/flint/types/fmpz_mpoly.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ cdef class fmpz_mpoly(flint_mpoly):
210210
raise ValueError("Cannot parse a polynomial without context")
211211
val = bytes(val, 'utf-8')
212212
init_fmpz_mpoly(self, ctx)
213-
fmpz_mpoly_set_str_pretty(self.val, val, self.ctx.c_names, self.ctx.val)
213+
if fmpz_mpoly_set_str_pretty(self.val, val, self.ctx.c_names, self.ctx.val) == -1:
214+
raise ValueError("Unable to parse fmpz_mpoly from string")
214215
fmpz_mpoly_sort_terms(self.val, self.ctx.val)
215216
else:
216217
v = any_as_fmpz(val)

0 commit comments

Comments
 (0)