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

Compiler crashes when with keyword is used in cppclass definition #2994

yifanmai opened this issue Jun 11, 2019 · 0 comments


None yet
1 participant
Copy link

commented Jun 11, 2019

The compiler crashes when with keyword is used in cppclass definition; it should return a user-facing error message instead of crashing.

Example source code:

cdef cppclass Hello:
  void hello():
    with open('hello.txt') as f:


Error compiling Cython file:
cdef cppclass Hello:
  void hello():
    with open('hello.txt') as f:

hello.pyx:3:9: Compiler crash in AnalyseDeclarationsTransform

ModuleNode.body = StatListNode(hello.pyx:1:5)
StatListNode.stats[0] = CppClassNode(hello.pyx:1:5,
    base_classes = [...]/0,
    name = u'Hello')
CppClassNode.attributes[0] = CFuncDefNode(hello.pyx:2:2,
    args = [...]/0,
    modifiers = [...]/0)
File '', line 431, in analyse_declarations: StatListNode(hello.pyx:3:9)
File '', line 7042, in analyse_declarations: WithStatNode(hello.pyx:3:9)

Compiler crash traceback from this point on:
  File "/home/yifanmai/.local/lib/python2.7/site-packages/Cython/Compiler/", line 7042, in analyse_declarations
AttributeError: 'NoneType' object has no attribute 'analyse_declarations'
Traceback (most recent call last):
  File "", line 5, in <module>
  File "/home/yifanmai/.local/lib/python2.7/site-packages/Cython/Build/", line 1097, in cythonize
  File "/home/yifanmai/.local/lib/python2.7/site-packages/Cython/Build/", line 1220, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: hello.pyx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.