Skip to content

Commit

Permalink
src/sage/misc/cython.py: Add doctests for PEP 420 support, cython/cyt…
Browse files Browse the repository at this point in the history
  • Loading branch information
tornaria authored and mkoeppe committed Mar 25, 2023
1 parent f13d6e9 commit 5ee730d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/sage/misc/cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,28 @@ def cython(filename, verbose=0, compile_message=False,
sage: cython('''
....: cdef size_t foo = 3/2
....: ''')
Check that Cython supports PEP 420 packages::
sage: cython('''
....: cimport sage.misc.cachefunc
....: ''')
sage: cython('''
....: from sage.misc.cachefunc cimport cache_key
....: ''')
In Cython 0.29.33 using `from PACKAGE cimport MODULE` is broken
when `PACKAGE` is a namespace package, see :trac:`35322`::
sage: cython('''
....: from sage.misc cimport cachefunc
....: ''')
Traceback (most recent call last):
...
RuntimeError: Error compiling Cython file:
...
...: 'sage/misc.pxd' not found
"""
if not filename.endswith('pyx'):
print("Warning: file (={}) should have extension .pyx".format(filename), file=sys.stderr)
Expand Down

0 comments on commit 5ee730d

Please sign in to comment.