Skip to content

Commit

Permalink
gh-37583: Workaround warning in cython 3.0.9 (#37560)
Browse files Browse the repository at this point in the history
    
A new warning in cython 3.0.9 breaks doctests
cython/cython#5999.

We filter this warning at runtime, as a quick workaround for 10.3.

For the future, we will need to remove the `noexcept` in question. Note
that these were mostly added in #36507 guided by a different warning
which is not quite right (see
cython/cython#5999 (comment)).

This has to be done with some care: about 2/3rds of the `noexcept` have
to be removed, but the other 1/3rd has to be kept. These changes are no-
ops as long as we use `legacy_implicit_noexcept=True` but it's important
to get it right before removing the legacy option. Hopefully we'll soon
have a version of cython which gives correct warnings so it's possible
to eliminate both types of warnings. Once there are no warnings left, we
can proceed to remove the legacy option.

### 📝 Checklist

- [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.

Fixes: #37560
    
URL: #37583
Reported by: Gonzalo Tornaría
Reviewer(s):
  • Loading branch information
Release Manager committed Mar 13, 2024
2 parents e850ac9 + cd652c6 commit 685e86b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/sage/misc/cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def cython(filename, verbose=0, compile_message=False,
...
RuntimeError: Error compiling Cython file:
...
...: 'sage/misc.pxd' not found
...: 'sage/misc.pxd' not found...
"""
if not filename.endswith('pyx'):
print("Warning: file (={}) should have extension .pyx".format(filename), file=sys.stderr)
Expand Down Expand Up @@ -382,6 +382,12 @@ def cython(filename, verbose=0, compile_message=False,
"Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.\n",
"", cython_messages, 0, re.MULTILINE)

# workaround for https://github.com/sagemath/sage/issues/37560
# triggered by Cython 3.0.9
cython_messages = re.sub(
"^warning: .*noexcept clause is ignored for function returning Python object\n",
"", cython_messages, 0, re.MULTILINE)

sys.stderr.write(cython_messages)
sys.stderr.flush()

Expand Down

0 comments on commit 685e86b

Please sign in to comment.