From ed5f0cafbed3741b2e29a5d7972b28066f6713f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 14 Feb 2022 21:13:34 +0100 Subject: [PATCH] fix coercion of Laurent into fraction fields --- src/sage/rings/fraction_field.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/sage/rings/fraction_field.py b/src/sage/rings/fraction_field.py index d5d392efba0..4872299ef08 100644 --- a/src/sage/rings/fraction_field.py +++ b/src/sage/rings/fraction_field.py @@ -291,6 +291,14 @@ def _coerce_map_from_(self, S): sage: 1/(R.gen(0) + R.gen(1)) 1/(x + y) + Test for :trac:`31320`:: + + sage: FQt = Frac(QQ['t']) + sage: LCt = LaurentPolynomialRing(CC,'t') + sage: coercion_model.common_parent(FQt, LCt) + Fraction Field of Univariate Polynomial Ring in t + over Complex Field with 53 bits of precision + Coercion from a localization:: sage: R. = ZZ[] @@ -333,7 +341,8 @@ def wrapper(x): parent_as_first_arg=False) # special treatment for LaurentPolynomialRings - if isinstance(S, LaurentPolynomialRing_generic): + if (isinstance(S, LaurentPolynomialRing_generic) and + self._R.has_coerce_map_from(S.base_ring())): def converter(x, y=None): if y is None: return self._element_class(self, *x._fraction_pair())