Describe the bug
Hi,
We're upgrading Cython from 3.2.9 to 3.3.0 in the freedesktop-sdk project (https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/merge_requests/34031) and found that aiohttp no longer compiles with the new version.
The failure is in aiohttp/_websocket/reader_c.py on this line:
ALLOWED_CLOSE_CODES: Final[set[int]] = {int(i) for i in WSCloseCode}
Cython 3.3.0 crashes with:
Compiler crash in AnalyseDeclarationsTransform
and eventually:
AttributeError: 'NoneType' object has no attribute 'assignable_from'
The relevant part of the traceback is:
File ".../Cython/Compiler/ExprNodes.py", line 2377, in _analyse_target_declaration
if not (annotation_type.assignable_from(entry_type) or entry_type.assignable_from(annotation_type)):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'assignable_from'
Cython 3.2.9 compiles the same source successfully.
We're seeing this with Python 3.14 (but can also produce on 3.13 & 3.12) and Cython 3.3.0.
For reference, this is the command being used to regenerate the C files:
python3 -m cython -3 -I aiohttp aiohttp/_websocket/reader_c.py
It looks like this may be related to the type inference for the set comprehension and/or the Final[set[int]] annotation.
I noticed that ALLOWED_CLOSE_CODES has also been discussed recently in #12918, although that appears to be for a different issue.
You can view a failing pipeline at https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/jobs/16049983973#L3941
To Reproduce
See above, try and build the latest version of the aiohttp source dist 3.14.3 with cython 3.3.0
Expected behavior
The compilation is successful
Logs/tracebacks
Error compiling Cython file:
------------------------------------------------------------
...
WSMessage,
WSMessageTextBytes,
WSMsgType,
)
ALLOWED_CLOSE_CODES: Final[set[int]] = {int(i) for i in WSCloseCode}
^
------------------------------------------------------------
aiohttp/_websocket/reader_c.py:22:0: Compiler crash in AnalyseDeclarationsTransform
File 'ModuleNode.py', line 297, in analyse_declarations: ModuleNode(reader_c.py:1:0,
doc = 'Reader for WebSocket protocol versions 13 and 8.',
full_module_name = 'aiohttp._websocket.reader_c')
File 'Nodes.py', line 426, in analyse_declarations: StatListNode(reader_c.py:3:0)
File 'Nodes.py', line 426, in analyse_declarations: StatListNode(reader_c.py:22:39)
File 'Nodes.py', line 6380, in analyse_declarations: SingleAssignmentNode(reader_c.py:22:39,
first = True)
File 'ExprNodes.py', line 2345, in analyse_target_declaration: NameNode(reader_c.py:22:0,
cf_maybe_null = True,
is_name = True,
is_target = True,
module_state_lookup = '',
name = 'ALLOWED_CLOSE_CODES',
result_is_used = True,
use_managed_ref = True)
File 'ExprNodes.py', line 2377, in _analyse_target_declaration: NameNode(reader_c.py:22:0,
cf_maybe_null = True,
is_name = True,
is_target = True,
module_state_lookup = '',
name = 'ALLOWED_CLOSE_CODES',
result_is_used = True,
use_managed_ref = True)
Compiler crash traceback from this point on:
File "/usr/lib/python3.14/site-packages/Cython/Compiler/ExprNodes.py", line 2377, in _analyse_target_declaration
if not (annotation_type.assignable_from(entry_type) or entry_type.assignable_from(annotation_type)):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'assignable_from'
Command 'for filename in $(grep -rl '/\* Generated by Cython'); do
rm -v ${filename}
basefile=$(echo ${filename} | cut -d"." -f1)
python3 -m cython -3 -I aiohttp ${basefile}.py*
done' failed with exitcode 1
Python Version
aiohttp Version
multidict Version
propcache Version
yarl Version
OS
Freedesktop-sdk based linux toolchain
Related component
Client
Additional context
No response
Code of Conduct
Describe the bug
Hi,
We're upgrading Cython from 3.2.9 to 3.3.0 in the freedesktop-sdk project (https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/merge_requests/34031) and found that aiohttp no longer compiles with the new version.
The failure is in
aiohttp/_websocket/reader_c.pyon this line:Cython 3.3.0 crashes with:
and eventually:
The relevant part of the traceback is:
Cython 3.2.9 compiles the same source successfully.
We're seeing this with Python 3.14 (but can also produce on 3.13 & 3.12) and Cython 3.3.0.
For reference, this is the command being used to regenerate the C files:
It looks like this may be related to the type inference for the set comprehension and/or the
Final[set[int]]annotation.I noticed that
ALLOWED_CLOSE_CODEShas also been discussed recently in #12918, although that appears to be for a different issue.You can view a failing pipeline at https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/jobs/16049983973#L3941
To Reproduce
See above, try and build the latest version of the aiohttp source dist 3.14.3 with cython 3.3.0
Expected behavior
The compilation is successful
Logs/tracebacks
Error compiling Cython file: ------------------------------------------------------------ ... WSMessage, WSMessageTextBytes, WSMsgType, ) ALLOWED_CLOSE_CODES: Final[set[int]] = {int(i) for i in WSCloseCode} ^ ------------------------------------------------------------ aiohttp/_websocket/reader_c.py:22:0: Compiler crash in AnalyseDeclarationsTransform File 'ModuleNode.py', line 297, in analyse_declarations: ModuleNode(reader_c.py:1:0, doc = 'Reader for WebSocket protocol versions 13 and 8.', full_module_name = 'aiohttp._websocket.reader_c') File 'Nodes.py', line 426, in analyse_declarations: StatListNode(reader_c.py:3:0) File 'Nodes.py', line 426, in analyse_declarations: StatListNode(reader_c.py:22:39) File 'Nodes.py', line 6380, in analyse_declarations: SingleAssignmentNode(reader_c.py:22:39, first = True) File 'ExprNodes.py', line 2345, in analyse_target_declaration: NameNode(reader_c.py:22:0, cf_maybe_null = True, is_name = True, is_target = True, module_state_lookup = '', name = 'ALLOWED_CLOSE_CODES', result_is_used = True, use_managed_ref = True) File 'ExprNodes.py', line 2377, in _analyse_target_declaration: NameNode(reader_c.py:22:0, cf_maybe_null = True, is_name = True, is_target = True, module_state_lookup = '', name = 'ALLOWED_CLOSE_CODES', result_is_used = True, use_managed_ref = True) Compiler crash traceback from this point on: File "/usr/lib/python3.14/site-packages/Cython/Compiler/ExprNodes.py", line 2377, in _analyse_target_declaration if not (annotation_type.assignable_from(entry_type) or entry_type.assignable_from(annotation_type)): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'assignable_from' Command 'for filename in $(grep -rl '/\* Generated by Cython'); do rm -v ${filename} basefile=$(echo ${filename} | cut -d"." -f1) python3 -m cython -3 -I aiohttp ${basefile}.py* done' failed with exitcode 1Python Version
3.14.7aiohttp Version
3.14.3multidict Version
6.7.1propcache Version
0.5.2yarl Version
1.24.5OS
Freedesktop-sdk based linux toolchain
Related component
Client
Additional context
No response
Code of Conduct