Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Compiler crashes when compiling hex numbers used in enum #5524

Closed
matusvalo opened this issue Jul 11, 2023 · 0 comments · Fixed by #5525
Closed

[BUG] Compiler crashes when compiling hex numbers used in enum #5524

matusvalo opened this issue Jul 11, 2023 · 0 comments · Fixed by #5525
Labels
Milestone

Comments

@matusvalo
Copy link
Contributor

Describe the bug

Compiling file with enum initialised with hex numbers crashes with traceback:

Error compiling Cython file:
------------------------------------------------------------
...
cdef enum SDL_BlendMode:
    SDL_BLENDMODE_NONE = 0x00000000,
    ^
------------------------------------------------------------

deleteme.pyx:2:4: Compiler crash in AnalyseDeclarationsTransform

File 'ModuleNode.py', line 203, in analyse_declarations: ModuleNode(deleteme.pyx:1:0,
    full_module_name = 'pygame.deleteme')
File 'Nodes.py', line 393, in analyse_declarations: StatListNode(deleteme.pyx:1:5)
File 'Nodes.py', line 1728, in analyse_declarations: CEnumDefNode(deleteme.pyx:1:5,
    name = 'SDL_BlendMode',
    visibility = 'private')
File 'Nodes.py', line 1786, in analyse_enum_declarations: CEnumDefItemNode(deleteme.pyx:2:4,
    name = 'SDL_BLENDMODE_NONE')

Compiler crash traceback from this point on:
  File "/Users/ness-skmac3/dev/cython/Cython/Compiler/Nodes.py", line 1786, in analyse_enum_declarations
    enum_value = int(self.value.value)
ValueError: invalid literal for int() with base 10: '0x00000000'

Code to reproduce the behaviour:

cdef enum SDL_BlendMode:
    SDL_BLENDMODE_NONE = 0x00000000,
    SDL_BLENDMODE_BLEND = 0x00000001,
    SDL_BLENDMODE_ADD = 0x00000002,
    SDL_BLENDMODE_MOD = 0x00000004,
    SDL_BLENDMODE_INVALID = 0x7FFFFFFF

Expected behaviour

Compilation success.

OS

any

Python version

any

Cython version

master

Additional context

Cython 0.29.X compiles example successfully

@matusvalo matusvalo added this to the 3.0 milestone Jul 11, 2023
da-woods added a commit to da-woods/cython that referenced this issue Jul 12, 2023
And other "special" integer constants.

Fixes cython#5524
scoder pushed a commit that referenced this issue Jul 12, 2023
And other "special" integer constants.

Fixes #5524
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant