Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests with gmp 6.3 #36006

Merged
merged 3 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/sage/ext/memory.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Low-level memory allocation functions

TESTS:

Check that a ``MemoryError`` is raised if we try to allocate a
Check that an error is raised if we try to allocate a
ridiculously large integer, see :trac:`15363`::

sage: 2^(2^63-3)
Traceback (most recent call last):
...
OverflowError: exponent must be at most 2147483647 # 32-bit
RuntimeError: Aborted # 64-bit
sage: try:
....: 2^(2^63-3)
....: except (OverflowError, RuntimeError, FloatingPointError):
....: print ('Overflow error')
...Overflow error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to have some explanation for the ... since it looks like we're already trying to list all of the possible errors and replace them with 'Overflow error'

Otherwise, the CI is happy now...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC the old gmp used to actually print some stuff in addition to an error; in the previous form of the test this would be catched by the ... of the traceback.

It'd feel better if sagemath would catch all these variations and return always the same exception (say OverflowError), then the doctest would document precisely what happens (unlike here where the doctest is documenting that different things can happen but we don't know which one).

I think getting this merged is still a win. Whoever feels inclined can improve this in a separate PR.


AUTHORS:

Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/integer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
sage: try:
....: print('Possible error output from gmp', flush=True)
....: 1 << (2^60)
....: except (MemoryError, OverflowError, RuntimeError):
....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
....: pass
....: else:
....: print("Failed to raise exception")
Expand Down