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

Open
yifanmai opened this issue Jun 11, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@yifanmai
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:
      pass

Output:

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 'Nodes.py', line 431, in analyse_declarations: StatListNode(hello.pyx:3:9)
File 'Nodes.py', 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/Nodes.py", line 7042, in analyse_declarations
    self.enter_call.analyse_declarations(env)
AttributeError: 'NoneType' object has no attribute 'analyse_declarations'
Traceback (most recent call last):
  File "setup.py", line 5, in <module>
    ext_modules=cythonize("hello.pyx"))
  File "/home/yifanmai/.local/lib/python2.7/site-packages/Cython/Build/Dependencies.py", line 1097, in cythonize
    cythonize_one(*args)
  File "/home/yifanmai/.local/lib/python2.7/site-packages/Cython/Build/Dependencies.py", 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.