Skip to content

Commit f789f22

Browse files
committed
check modulus for nmod_poly and fmpz_mod_poly
1 parent e79b397 commit f789f22

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/flint/types/fq_default.pyx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,15 +362,11 @@ cdef class fq_default_ctx:
362362
if check is not NotImplemented:
363363
return 0
364364

365-
# Assumes that the modulus of the polynomial matches
366-
# the context for the fq_default
367-
if typecheck(obj, fmpz_mod_poly):
365+
if typecheck(obj, fmpz_mod_poly) and self.prime() == (<fmpz_mod_poly>obj).ctx.mod.modulus():
368366
fq_default_set_fmpz_mod_poly(fq_ele, (<fmpz_mod_poly>obj).val, self.val)
369367
return 0
370368

371-
# Assumes that the modulus of the polynomial matches
372-
# the context for the fq_default
373-
if typecheck(obj, nmod_poly):
369+
if typecheck(obj, nmod_poly) and self.prime() == obj.modulus():
374370
fq_default_set_nmod_poly(fq_ele, (<nmod_poly>obj).val, self.val)
375371
return 0
376372

0 commit comments

Comments
 (0)