Skip to content

Commit 1165bb0

Browse files
hroncokserge-sans-paille
authored andcommitted
Fix typing of array.typecodes for Python 3.15
Python 3.15 changed array.typecodes from str to tuple to support type codes longer than 1 character (Zf and Zd). See python/cpython#148675 Pythran's fill_constants_types() uses type() introspection on live Python constants to set signatures, which now produces tuple instead of str. Meanwhile, the explicit ConstantIntr(signature=str) was silently ignored because ConstantIntr.__init__ never stored it. Fix ConstantIntr to preserve an explicitly provided signature, and skip introspection in fill_constants_types when one is already set. Without the fix, pytest pythran/tests/test_array.py -k test_typecodes fails with: else: > raise NotImplementedError(t) E NotImplementedError: <class 'tuple'> pythran/types/tog.py:480: NotImplementedError Assisted-By: Claude Opus 4.6
1 parent 6e3af75 commit 1165bb0

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎pythran/intrinsic.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ def __init__(self, **kwargs):
255255
""" Forward arguments and remove arguments effects. """
256256
kwargs["argument_effects"] = ()
257257
super(ConstantIntr, self).__init__(**kwargs)
258+
if 'signature' in kwargs:
259+
self.signature = kwargs['signature']
258260

259261
def isliteral(self):
260262
""" Mark this intrinsic as a literal. """

‎pythran/tables.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4731,9 +4731,10 @@ def fill_constants_types(module_name, elements):
47314731
if isinstance(intrinsic, dict): # Submodule case
47324732
fill_constants_types(module_name + (elem,), intrinsic)
47334733
elif isinstance(intrinsic, ConstantIntr):
4734-
# use introspection to get the Python constants types
4735-
cst = getattr(import_module(".".join(module_name)), elem)
4736-
intrinsic.signature = type(cst)
4734+
if not hasattr(intrinsic, 'signature'):
4735+
# use introspection to get the Python constants types
4736+
cst = getattr(import_module(".".join(module_name)), elem)
4737+
intrinsic.signature = type(cst)
47374738

47384739

47394740
fill_constants_types((), MODULES)

0 commit comments

Comments
 (0)