Commit 98319229 authored by da-woods's avatar da-woods Committed by GitHub

Make the fused dispatch function safe w.r.t. user defined wraparound/boundscheck (GH-3493)

The directives are currently inherited from user code, which is not correct, but it seemed difficult to reliably change the directives applied to the `__pyx_fused_cpdef` dispatch function, so instead the code was changed to be independent.

Fixes https://github.com/cython/cython/issues/3492
parent c43bd777
......@@ -594,13 +594,13 @@ class FusedCFuncDefNode(StatListNode):
if not _fused_sigindex:
for sig in <dict>signatures:
sigindex_node = _fused_sigindex
sig_series = sig.strip('()').split('|')
for sig_type in sig_series[:-1]:
*sig_series, last_type = sig.strip('()').split('|')
for sig_type in sig_series:
if sig_type not in sigindex_node:
sigindex_node[sig_type] = sigindex_node = {}
else:
sigindex_node = sigindex_node[sig_type]
sigindex_node[sig_series[-1]] = sig
sigindex_node[last_type] = sig
"""
)
......
# mode: compile
# tag: fused, werror
"""
Very short test for https://github.com/cython/cython/issues/3492
(Needs its own file since werror fails on the main fused-test files)
wraparound and boundscheck directives shouldn't break the fused
dispatcher function
"""
cimport cython
ctypedef fused fused_t:
str
int
long
complex
@cython.wraparound(False)
@cython.boundscheck(False)
def func(fused_t a, cython.floating b):
return a, b
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment