Skip to content

Commit f0870b9

Browse files
author
Release Manager
committed
gh-39050: Fix exactify caching when interrupted Fix a certain `AttributeError` — if you run the newly added test under previous version of SageMath then it will give an `AttributeError` in the last line instead. (ideally you'd want some polynomial where `exactify()` takes exactly 1 second, use `alarm(0.5)` in first case and no `alarm()` in the second case to get the correct result — but finding such a polynomial is not easy, and timing result varies over machines/versions anyway) ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. (not aware of one) - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #39050 Reported by: user202729 Reviewer(s): Travis Scrimshaw
2 parents 39e75dd + 3ca55fe commit f0870b9

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/sage/rings/qqbar.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7098,12 +7098,26 @@ def exactify(self):
70987098
sage: cp.exactify()
70997099
sage: cp._exact
71007100
True
7101+
7102+
TESTS:
7103+
7104+
Check that interrupting ``exactify()`` does not lead to incoherent state::
7105+
7106+
sage: x = polygen(AA)
7107+
sage: p = AA(2)^(1/100) * x + AA(3)^(1/100)
7108+
sage: cp = AA.common_polynomial(p)
7109+
sage: alarm(0.5); cp.generator()
7110+
Traceback (most recent call last):
7111+
...
7112+
AlarmInterrupt
7113+
sage: alarm(0.5); cp.generator()
7114+
Traceback (most recent call last):
7115+
...
7116+
AlarmInterrupt
71017117
"""
71027118
if self._exact:
71037119
return
71047120

7105-
self._exact = True
7106-
71077121
if self._poly.base_ring() is QQ:
71087122
self._factors = [fac_exp[0] for fac_exp in self._poly.factor()]
71097123
self._gen = qq_generator
@@ -7128,6 +7142,8 @@ def exactify(self):
71287142

71297143
self._factors = [fac_exp[0] for fac_exp in fp.factor()]
71307144

7145+
self._exact = True
7146+
71317147
def factors(self):
71327148
r"""
71337149
EXAMPLES::

0 commit comments

Comments
 (0)