Closed
Description
Describe the bug
The cython compiler crashes when analysing a class method that has a memory view with a default None
value with the following traceback
analyse_types not implemented
Called from: CoerceToMemViewSliceNode.not_implemented 485
Called from: CoerceToMemViewSliceNode.analyse_types 719
Called from: TupleNode.analyse_types 8084
Called from: PyCFunctionNode.analyse_default_args 9493
Called from: PyCFunctionNode.analyse_types 9410
Called from: SingleAssignmentNode.analyse_types 5827
Called from: SingleAssignmentNode.analyse_expressions 5707
Called from: <listcomp> 396
Called from: StatListNode.analyse_expressions 396
Called from: CClassDefNode.analyse_expressions 5233
Called from: <listcomp> 396
Called from: StatListNode.analyse_expressions 396
Called from: AnalyseExpressionsTransform.visit_ModuleNode 2351
Called from: run 352
Called from: run_pipeline 372
Called from: run_pipeline 505
Called from: compile_multiple 607
Called from: compile 630
Called from: main 732
Called from: setuptools_main 714
Called from: <module> 8
----------------------------------------------------------------------
Error compiling Cython file:
------------------------------------------------------------
...
cdef class Foo:
def test(self, int[:] bar = None):
^
------------------------------------------------------------
test.pyx:2:32: Compiler crash in AnalyseExpressionsTransform
File 'Nodes.py', line 396, in analyse_expressions: StatListNode(test.pyx:1:5)
File 'Nodes.py', line 5233, in analyse_expressions: CClassDefNode(test.pyx:1:5,
as_name = 'Foo',
class_name = 'Foo',
module_name = '',
punycode_class_name = 'Foo',
visibility = 'private')
File 'Nodes.py', line 396, in analyse_expressions: StatListNode(test.pyx:2:4)
File 'Nodes.py', line 5707, in analyse_expressions: SingleAssignmentNode(test.pyx:2:4)
File 'Nodes.py', line 5827, in analyse_types: SingleAssignmentNode(test.pyx:2:4)
File 'ExprNodes.py', line 9410, in analyse_types: PyCFunctionNode(test.pyx:2:4,
binding = True,
is_temp = 1,
pymethdef_cname = '__pyx_mdef_4test_3Foo_1test',
result_is_used = True,
use_managed_ref = True)
File 'ExprNodes.py', line 9493, in analyse_default_args: PyCFunctionNode(test.pyx:2:4,
binding = True,
is_temp = 1,
pymethdef_cname = '__pyx_mdef_4test_3Foo_1test',
result_is_used = True,
use_managed_ref = True)
File 'ExprNodes.py', line 8084, in analyse_types: TupleNode(test.pyx:2:4,
is_sequence_constructor = 1,
result_is_used = True,
use_managed_ref = True)
File 'ExprNodes.py', line 719, in analyse_types: CoerceToMemViewSliceNode(test.pyx:2:32,
is_temp = 1,
result_is_used = True,
use_managed_ref = True)
File 'ExprNodes.py', line 486, in not_implemented: CoerceToMemViewSliceNode(test.pyx:2:32,
is_temp = 1,
result_is_used = True,
use_managed_ref = True)
Compiler crash traceback from this point on:
File "/home/ccc/anaconda3/envs/py39/lib/python3.9/site-packages/Cython/Compiler/ExprNodes.py", line 486, in not_implemented
raise InternalError(
InternalError: Internal compiler error: CoerceToMemViewSliceNode.analyse_types not implemented
To Reproduce
Minimal code to reproduce the behaviour:
# This results in a compiler crash
cdef class Foo:
def test(self, int[:] bar = None):
pass
Note that the compiler properly handles the following
# This compiles fine
def test(int[:] bar = None):
pass
Expected behavior
The code should compile fine.
Environment (please complete the following information):
- OS: Linux
- Python version 3.7.11 and 3.9.5
- Cython version 3.0a7, 3.0.0a8, 3.0.0a9 (works on any version <=3.0a6)
Additional information:
The traceback above is with Python 3.9.5 and Cython 3.0.0a9.