From 0da9e555288f2de3cf534003a2edd728af025fd2 Mon Sep 17 00:00:00 2001 From: Emergency Self-Construct Date: Tue, 4 Nov 2025 15:59:10 +0100 Subject: [PATCH 1/5] fix use of flag 0x10/16 in SET_FUNCTION_ATTRIBUTE As title --- numba_cuda/numba/cuda/core/byteflow.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/numba_cuda/numba/cuda/core/byteflow.py b/numba_cuda/numba/cuda/core/byteflow.py index 46eef06f9..74ca60595 100644 --- a/numba_cuda/numba/cuda/core/byteflow.py +++ b/numba_cuda/numba/cuda/core/byteflow.py @@ -1866,19 +1866,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 == 1: # 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 == 2: # 0x02 a tuple of strings containing parameters’ annotations state.set_function_attribute(make_func_stack, kwdefaults=data) - elif inst.arg & 0x4: + elif inst.arg == 4: # 0x04 a tuple of strings containing parameters’ annotations state.set_function_attribute(make_func_stack, annotations=data) - elif inst.arg == 0x8: + elif inst.arg == 8: # 0x08 a tuple containing cells for free variables, making a closure state.set_function_attribute(make_func_stack, closure=data) + elif inst.arg == 16: + # 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, annotations=data) else: raise AssertionError("unreachable") state.push(make_func_stack) From cb75f7eb08f8758ff3b4eb4a1496d3961d2bc3c4 Mon Sep 17 00:00:00 2001 From: Emergency Self-Construct Date: Tue, 4 Nov 2025 16:36:27 +0100 Subject: [PATCH 2/5] fix :: annotations -> annotate As title --- numba_cuda/numba/cuda/core/byteflow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numba_cuda/numba/cuda/core/byteflow.py b/numba_cuda/numba/cuda/core/byteflow.py index 74ca60595..6b1d6c229 100644 --- a/numba_cuda/numba/cuda/core/byteflow.py +++ b/numba_cuda/numba/cuda/core/byteflow.py @@ -1882,7 +1882,7 @@ def op_SET_FUNCTION_ATTRIBUTE(self, state, inst): elif inst.arg == 16: # 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, annotations=data) + state.set_function_attribute(make_func_stack, annotate=data) else: raise AssertionError("unreachable") state.push(make_func_stack) From c1983003cd32dd7ac8dee9d0bd1f6ddc3f385f86 Mon Sep 17 00:00:00 2001 From: Emergency Self-Construct Date: Wed, 5 Nov 2025 14:31:17 +0100 Subject: [PATCH 3/5] wire through annotate to ignore it As title --- numba_cuda/numba/cuda/core/byteflow.py | 3 ++- numba_cuda/numba/cuda/core/interpreter.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/numba_cuda/numba/cuda/core/byteflow.py b/numba_cuda/numba/cuda/core/byteflow.py index 6b1d6c229..2fb52a34a 100644 --- a/numba_cuda/numba/cuda/core/byteflow.py +++ b/numba_cuda/numba/cuda/core/byteflow.py @@ -1835,7 +1835,7 @@ 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 @@ -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, diff --git a/numba_cuda/numba/cuda/core/interpreter.py b/numba_cuda/numba/cuda/core/interpreter.py index 2db457e7a..ae652d62c 100644 --- a/numba_cuda/numba/cuda/core/interpreter.py +++ b/numba_cuda/numba/cuda/core/interpreter.py @@ -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) From 1774b7400a41f878e8ff4cbcbf064eab260be697 Mon Sep 17 00:00:00 2001 From: Emergency Self-Construct Date: Wed, 5 Nov 2025 14:32:56 +0100 Subject: [PATCH 4/5] update code comment As title --- numba_cuda/numba/cuda/core/byteflow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numba_cuda/numba/cuda/core/byteflow.py b/numba_cuda/numba/cuda/core/byteflow.py index 2fb52a34a..7c544c950 100644 --- a/numba_cuda/numba/cuda/core/byteflow.py +++ b/numba_cuda/numba/cuda/core/byteflow.py @@ -1839,7 +1839,7 @@ def op_MAKE_FUNCTION(self, state, inst, MAKE_CLOSURE=False): 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() From 58c2ffabb26df730f4ed30ca2e26a9e65959f950 Mon Sep 17 00:00:00 2001 From: Emergency Self-Construct Date: Wed, 5 Nov 2025 14:55:38 +0100 Subject: [PATCH 5/5] use hex and binary AND instead of ints and equals This syntax choice is like what the upstream cpython does. --- numba_cuda/numba/cuda/core/byteflow.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/numba_cuda/numba/cuda/core/byteflow.py b/numba_cuda/numba/cuda/core/byteflow.py index 7c544c950..82e535048 100644 --- a/numba_cuda/numba/cuda/core/byteflow.py +++ b/numba_cuda/numba/cuda/core/byteflow.py @@ -1867,20 +1867,20 @@ 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 == 1: + 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 == 2: + elif inst.arg & 0x02: # 0x02 a tuple of strings containing parameters’ annotations state.set_function_attribute(make_func_stack, kwdefaults=data) - elif inst.arg == 4: + elif inst.arg & 0x04: # 0x04 a tuple of strings containing parameters’ annotations state.set_function_attribute(make_func_stack, annotations=data) - elif inst.arg == 8: + 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 == 16: + 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)