Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions numba_cuda/numba/cuda/core/byteflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1835,11 +1835,11 @@ def op_MAKE_FUNCTION(self, state, inst, MAKE_CLOSURE=False):
else:
raise NotImplementedError(PYVERSION)
code = state.pop()
closure = annotations = kwdefaults = defaults = None
closure = annotations = annotate = kwdefaults = defaults = None
if PYVERSION in ((3, 13), (3, 14)):
assert inst.arg is None
# SET_FUNCTION_ATTRIBUTE is responsible for setting
# closure, annotations, kwdefaults and defaults.
# closure, annotations, annotate, kwdefaults and defaults.
else:
if inst.arg & 0x8:
closure = state.pop()
Expand All @@ -1856,6 +1856,7 @@ def op_MAKE_FUNCTION(self, state, inst, MAKE_CLOSURE=False):
code=code,
closure=closure,
annotations=annotations,
annotate=annotate,
kwdefaults=kwdefaults,
defaults=defaults,
res=res,
Expand All @@ -1866,19 +1867,23 @@ def op_SET_FUNCTION_ATTRIBUTE(self, state, inst):
assert PYVERSION in ((3, 13), (3, 14))
make_func_stack = state.pop()
data = state.pop()
if inst.arg == 0x1:
if inst.arg & 0x01:
# 0x01 a tuple of default values for positional-only and
# positional-or-keyword parameters in positional order
state.set_function_attribute(make_func_stack, defaults=data)
elif inst.arg & 0x2:
elif inst.arg & 0x02:
# 0x02 a tuple of strings containing parameters’ annotations
state.set_function_attribute(make_func_stack, kwdefaults=data)
elif inst.arg & 0x4:
elif inst.arg & 0x04:
# 0x04 a tuple of strings containing parameters’ annotations
state.set_function_attribute(make_func_stack, annotations=data)
elif inst.arg == 0x8:
elif inst.arg & 0x08:
# 0x08 a tuple containing cells for free variables, making a closure
state.set_function_attribute(make_func_stack, closure=data)
elif inst.arg & 0x10:
# In 3.14 a new flag was added it has the value 0x10/16
# Numba report: https://github.com/numba/numba/issues/10319
state.set_function_attribute(make_func_stack, annotate=data)
else:
raise AssertionError("unreachable")
state.push(make_func_stack)
Expand Down
13 changes: 12 additions & 1 deletion numba_cuda/numba/cuda/core/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3504,10 +3504,21 @@ def op_YIELD_VALUE(self, inst, value, res):
return self.store(inst, res)

def op_MAKE_FUNCTION(
self, inst, name, code, closure, annotations, kwdefaults, defaults, res
self,
inst,
name,
code,
closure,
annotations,
annotate,
kwdefaults,
defaults,
res,
):
# annotations are ignored by numba but useful for static analysis
# re. https://github.com/numba/numba/issues/7269
# annotate is ignored too
# re. https://github.com/numba/numba/pull/10321
if kwdefaults is not None:
msg = "op_MAKE_FUNCTION with kwdefaults is not implemented"
raise NotImplementedError(msg)
Expand Down