Skip to content

GR maintenance#2591

Merged
fredrik-johansson merged 2 commits intoflintlib:mainfrom
fredrik-johansson:gr2
Mar 5, 2026
Merged

GR maintenance#2591
fredrik-johansson merged 2 commits intoflintlib:mainfrom
fredrik-johansson:gr2

Conversation

@fredrik-johansson
Copy link
Collaborator

We add a special gr_ctx_uninitialized constructor and call this in GR context initializers that have the ability to fail, e.g. mpn_mod with a modulus that is out of range. This makes it a bit forgiving to write wrappers and cleanup blocks for generics, since it becomes safe to call gr_ctx_clear even if initialization failed. Indeed, thanks to this change context initialization should now fail gracefully in the ctypes wrapper instead of randomly segfaulting.

IIRC @mezzarobba requested something like this.

Not sure if we should actually call gr_ctx_uninitialized in the failing constructors ourselves or leave this to the user? I made this automatic for now in all places I could think of, but I don't have a strong opinion either way.

Also, add ctypes wrapper for gr_fraction with some tests.

@fredrik-johansson fredrik-johansson merged commit 505c60f into flintlib:main Mar 5, 2026
12 of 13 checks passed
@fredrik-johansson fredrik-johansson deleted the gr2 branch March 5, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant