Ticket #135 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years ago

bad code segment crashes cython

Reported by: hoytak Owned by: ksmith
Priority: major Milestone: 0.11.3
Component: Type Analysis Keywords:
Cc: ksmith

Description

Hello,

The following (bad) code segment crashes cython:

cdef class A:
    return None

The traceback is:

  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Distutils/build_ext.py", line 196, in cython_sources
    full_module_name=module_name)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 692, in compile
    return compile_single(source, options, full_module_name)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 637, in compile_single
    return run_pipeline(source, options, full_module_name)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 526, in run_pipeline
    err, enddata = context.run_pipeline(pipeline, source)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 185, in run_pipeline
    data = phase(data)
  File "Visitor.py", line 177, in Cython.Compiler.Visitor.CythonTransform.__call__ (/home/hoytak/sysroot/src/cython/Cython/Compiler/Visitor.c:2162)
  File "Visitor.py", line 163, in Cython.Compiler.Visitor.VisitorTransform.__call__ (/home/hoytak/sysroot/src/cython/Cython/Compiler/Visitor.c:1924)
  File "Visitor.py", line 43, in Cython.Compiler.Visitor.BasicVisitor.visit (/home/hoytak/sysroot/src/cython/Cython/Compiler/Visitor.c:901)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 605, in visit_ModuleNode
    node.body.analyse_expressions(node.scope)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 318, in analyse_expressions
    stat.analyse_expressions(env)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 2534, in analyse_expressions
    self.body.analyse_expressions(scope)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 318, in analyse_expressions
    stat.analyse_expressions(env)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 3224, in analyse_expressions
    return_type = env.return_type
AttributeError: CClassScope instance has no attribute 'return_type'

I'm using changset 1374

--Hoyt

Attachments

ticket-135.patch Download (1.8 KB) - added by ksmith 4 years ago.

Change History

Changed 4 years ago by dagss

  • priority changed from minor to major
  • milestone changed from wishlist to 0.11.1

Changed 4 years ago by ksmith

See above patch for a possible fix.

In the Scope object initialization, it sets the return_type to None; this covers both cases when there is a return in the module scope and a class scope.

Test case in the patch too.

Changed 4 years ago by ksmith

Changed 4 years ago by ksmith

  • cc ksmith added

Changed 4 years ago by scoder

  • component changed from Parsing to Type Analysis
  • milestone changed from 0.11.1 to 0.12

The proposed patch does not fix the underlying problem that the "return_type" should not be accessed before the code generation phase.

This should be fixed as part of the refactoring for ticket #144.

Changed 4 years ago by robertwb

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from 0.12 to 0.11.3

Changed 4 years ago by robertwb

  • status changed from closed to reopened
  • resolution fixed deleted

Changed 4 years ago by robertwb

  • owner changed from somebody to ksmith
  • status changed from reopened to new

Changed 4 years ago by robertwb

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