summaryrefslogtreecommitdiff
path: root/tests/build/cythonize_options.srctree
blob: fcef9645bbbd62d3168c6651c6a2b91bb6e7bcbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# mode: run

PYTHON setup.py build_ext --inplace
PYTHON -c "import a"

######## setup.py ########

from Cython.Build.Dependencies import cythonize

import sys
from distutils.core import setup
try:
    # io.StringIO cannot handle 'str' in Py2
    from StringIO import StringIO
except ImportError:
    from io import StringIO

old_stderr = sys.stderr
captured = sys.stderr = StringIO()
try:
    setup(
      ext_modules = cythonize(
          "*.pyx", include_path=['subdir'],
          compiler_directives={'cdivision': True},
          show_all_warnings=True,
      ),
    )
    output = sys.stderr.getvalue()
finally:
    sys.stderr = old_stderr
    sys.stderr.write(captured.getvalue())

assert "Unraisable exception in function" in output, output


######## subdir/x.pxd ########

######## subdir/y.pxi ########

######## a.pyx ########

cimport x
include "y.pxi"

# cdivision from setup.py
def mod_int_c(int a, int b):
    return a % b

assert mod_int_c(-1, 10) < 0

# unraisable exceptions should produce a warning
cdef int no_exc_propagate():
    raise TypeError()