Opened 6 years ago

Closed 6 years ago

#165 closed defect (fixed)

cython crashes on cpdef without "self"

Reported by: hoytak Owned by: robertwb
Priority: minor Milestone: 0.11.1
Component: Parsing Keywords:
Cc:

Description

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.

Change History (5)

comment:1 Changed 6 years ago by scoder

  • Milestone changed from wishlist to 0.11.1

Test added as -T165.

comment:2 Changed 6 years ago by dagss

  • Summary changed from cython fails with RunTimeError when compiling bad code. to cython crashes on cpdef without "self"

comment:3 Changed 6 years ago by robertwb

  • Owner changed from somebody to robertwb

comment:5 Changed 6 years ago by robertwb

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.