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

cython crashes on cpdef without "self" #723

Closed
robertwb opened this issue Dec 16, 2008 · 5 comments
Closed

cython crashes on cpdef without "self" #723

robertwb opened this issue Dec 16, 2008 · 5 comments

Comments

@robertwb
Copy link
Contributor

Hello,

As of version 1497, the following bad code causes cython to fail after printing an error message.

cdef class A:
    cpdef a(int allocated_rows):
        pass

This produces the following output:

Error converting Pyrex file to C:
------------------------------------------------------------
...                                                         
cdef class A:                                               
    cpdef a(int allocated_rows):                            
         ^                                                  
------------------------------------------------------------

/home/hoytak/workspace/cython-tests/temp_allocated_prob.pyx:2:10: Self argument of C method does not match parent type
Traceback (most recent call last):
  File "/home/hoytak/sysroot/bin/cython", line 8, in <module>
    main(command_line = 1)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 729, in main
    result = compile(sources, options)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 706, in compile
    return compile_multiple(source, options)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 676, in compile_multiple
    result = run_pipeline(source, options)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 538, in run_pipeline
    err, enddata = context.run_pipeline(pipeline, source)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 197, in run_pipeline
    data = phase(data)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 138, in generate_pyx_code
    module_node.process_implementation(options, result)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ModuleNode.py", line 70, in process_implementation
    self.generate_c_code(env, options, result)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ModuleNode.py", line 263, in generate_c_code
    self.body.generate_function_definitions(env, code)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 323, in generate_function_definitions
    stat.generate_function_definitions(env, code)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 2569, in generate_function_definitions
    self.entry.type.scope, code)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 323, in generate_function_definitions
    stat.generate_function_definitions(env, code)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 1146, in generate_function_definitions
    self.py_func.generate_function_definitions(env, code)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 1046, in generate_function_definitions
    self.body.generate_execution_code(code)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 3294, in generate_execution_code
    self.value.generate_evaluation_code(code)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ExprNodes.py", line 677, in generate_evaluation_code
    self.generate_subexpr_evaluation_code(code)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ExprNodes.py", line 465, in generate_subexpr_evaluation_code
    node.generate_evaluation_code(code)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ExprNodes.py", line 680, in generate_evaluation_code
    self.allocate_temp_result(code)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ExprNodes.py", line 646, in allocate_temp_result
    raise RuntimeError("Temp allocated multiple times")
RuntimeError: Temp allocated multiple times

It works correctly (printing the error message and then exiting) when the cpdef is replaced by cdef. If it is replaced by def, it doesn't raise an error (separate issue?).

Note that this is probably related to http://trac.cython.org/cython_trac/ticket/156.

Migrated from http://trac.cython.org/ticket/165

@robertwb
Copy link
Contributor Author

robertwb commented Mar 8, 2009

scoder changed milestone from wishlist to 0.11.1
commented

Test added as -T165.

@robertwb
Copy link
Contributor Author

@dagss changed summary from

cython fails with RunTimeError when compiling bad code.

to

cython crashes on cpdef without "self"
commented

@robertwb
Copy link
Contributor Author

@robertwb changed owner from somebody to robertwb
commented

@robertwb
Copy link
Contributor Author

@robertwb commented

Fix in unstable branch http://hg.cython.org/cython-unstable/rev/3aac44b1f28a

@robertwb
Copy link
Contributor Author

robertwb commented Apr 3, 2009

@robertwb changed resolution to fixed
status from new to closed
commented

http://hg.cython.org/cython-devel/rev/3aac44b1f28a

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

No branches or pull requests

1 participant