Skip to content

Commit

Permalink
Trac #28036: Fix infinite loop from #21161 - repr of NumberFields (th…
Browse files Browse the repository at this point in the history
…e 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
  • Loading branch information
Release Manager committed Jun 22, 2019
2 parents 8084b69 + c44fd16 commit 4d1cf50
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/sage/rings/number_field/number_field.py
Expand Up @@ -1913,7 +1913,9 @@ def _Hom_(self, codomain, category=None):
True
"""
if not is_NumberFieldHomsetCodomain(codomain):
raise TypeError("{} is not suitable as codomain for homomorphisms from {}".format(codomain, self))
# Using LazyFormat fixes #28036 - infinite loop
from sage.misc.lazy_format import LazyFormat
raise TypeError(LazyFormat("%s is not suitable as codomain for homomorphisms from %s") % (codomain, self))
from .morphism import NumberFieldHomset
return NumberFieldHomset(self, codomain, category)

Expand Down

0 comments on commit 4d1cf50

Please sign in to comment.