Skip to content

Commit 4d1cf50

Browse files
author
Release Manager
committed
Trac #28036: Fix infinite loop from #21161 - repr of NumberFields (the parents) should indicate its embedding if there is one
Because this is causing some random infinite loops when running the testsuite. To reproduce, as reported in https://github.com/cschwan/sage- on-gentoo/issues/541, use: {{{ sage -t --long src/sage/structure/ src/sage/interfaces/ }}} Another symptom: The doctest {{{ File "src/sage/structure/parent.pyx", line 1734, in sage.structure.parent.Parent.hom.register_embedding Failed example: K.coerce_embedding()(a) }}} when it does not fail, and then one calls {{{ K.coerce_embedding() }}} again, makes sage crash. Removing the change of repr made in #21161 fixes that. For the complete log when the doctest fails, see for example https://patchbot.sagemath.org/log/27408/Ubuntu/18.04/x86_64/4.15.0-52-ge neric/petitbonum/2019-06-20%2014:50:38?short URL: https://trac.sagemath.org/28036 Reported by: chapoton Ticket author(s): Matthias Koeppe Reviewer(s): Volker Braun
2 parents 8084b69 + c44fd16 commit 4d1cf50

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/sage/rings/number_field/number_field.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,9 @@ def _Hom_(self, codomain, category=None):
19131913
True
19141914
"""
19151915
if not is_NumberFieldHomsetCodomain(codomain):
1916-
raise TypeError("{} is not suitable as codomain for homomorphisms from {}".format(codomain, self))
1916+
# Using LazyFormat fixes #28036 - infinite loop
1917+
from sage.misc.lazy_format import LazyFormat
1918+
raise TypeError(LazyFormat("%s is not suitable as codomain for homomorphisms from %s") % (codomain, self))
19171919
from .morphism import NumberFieldHomset
19181920
return NumberFieldHomset(self, codomain, category)
19191921

0 commit comments

Comments
 (0)