Skip to content

Commit 4761163

Browse files
committed
Drop PyFPE macros
These macros stopped doing anything in Python 3.7 (and may have been broken before): python/cpython#73323. This has the side-effect of fixing basic arthmetic in the limited API.
1 parent e0d2a36 commit 4761163

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎Cython/Utility/Optimize.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,10 +1318,7 @@ static {{c_ret_type}} {{cfunc_name}}(PyObject *op1, PyObject *op2, long intval,
13181318
{{else}}
13191319
double result;
13201320
{{zerodiv_check('b', 'float')}}
1321-
// copied from floatobject.c in Py3.5:
1322-
PyFPE_START_PROTECT("{{op.lower() if not op.endswith('Divide') else 'divide'}}", return NULL)
13231321
result = ((double)a) {{c_op}} (double)b;
1324-
PyFPE_END_PROTECT(result)
13251322
return PyFloat_FromDouble(result);
13261323
{{endif}}
13271324
}

‎tests/run/isolated_limited_api_tests.srctree‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ assert limited.cast_float(1) == 1.0
4646
assert limited.cast_float("2.0") == 2.0
4747
assert limited.cast_float(bytearray(b"3")) == 3.0
4848

49+
assert limited.add_one(2) == 3
50+
4951

5052
##################### limited.pyx #############################
5153

@@ -72,6 +74,9 @@ def lsum(values):
7274
for value in reversed(<tuple>values):
7375
result += value
7476
return result
77+
78+
def add_one(value):
79+
return value + 1
7580

7681
@cython.binding(False)
7782
def raises():

0 commit comments

Comments
 (0)