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

cpdef method w/ no self crashes cython #714

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

cpdef method w/ no self crashes cython #714

robertwb opened this issue Dec 9, 2008 · 5 comments

Comments

@robertwb
Copy link
Contributor

robertwb commented Dec 9, 2008

Hello,

In version 1474:7f1b96cad687, the following code crashes the compiler:

cdef class A:
    cpdef foo(): 
        pass

Note that foo() should be foo(self). If you replace the cpdef with either def or cdef, the error is correctly reported and cython works fine. With the above code segment, however, we get the following error in addition to the error report:

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

/home/hoytak/workspace/cython-tests/paramstruct.pyx:2:10: C method has no self argument
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 728, in main
    result = compile(sources, options)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 705, in compile
    return compile_multiple(source, options)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 675, in compile_multiple
    result = run_pipeline(source, options)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 537, in run_pipeline
    err, enddata = context.run_pipeline(pipeline, source)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Main.py", line 196, in run_pipeline
    data = phase(data)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 595, in __call__
    return super(AnalyseDeclarationsTransform, self).__call__(root)
  File "Visitor.py", line 177, in Cython.Compiler.Visitor.CythonTransform.__call__ (/home/hoytak/sysroot/src/cython/Cython/Compiler/Visitor.c:2365)
  File "Visitor.py", line 163, in Cython.Compiler.Visitor.VisitorTransform.__call__ (/home/hoytak/sysroot/src/cython/Cython/Compiler/Visitor.c:2109)
  File "Visitor.py", line 43, in Cython.Compiler.Visitor.BasicVisitor.visit (/home/hoytak/sysroot/src/cython/Cython/Compiler/Visitor.c:955)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 598, in visit_ModuleNode
    node.analyse_declarations(self.env_stack[ File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/ModuleNode.py", line 58, in analyse_declarations
    self.body.analyse_declarations(env)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 313, in analyse_declarations
    stat.analyse_declarations(env)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 2553, in analyse_declarations
    self.body.analyse_declarations(scope)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 313, in analyse_declarations
    stat.analyse_declarations(env)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 1262, in analyse_declarations
    py_func_body = self.call_self_node(is_module_scope = env.is_module_scope)
  File "/home/hoytak/sysroot/lib/python2.5/site-packages/Cython/Compiler/Nodes.py", line 1291, in call_self_node
    self_arg = ExprNodes.NameNode(self.pos, name=arg_names[0](-1])
))
IndexError: list index out of range

Thanks!

--Hoyt

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

@robertwb
Copy link
Contributor Author

@dagss changed milestone from wishlist to 0.11.1
commented

@robertwb
Copy link
Contributor Author

@dagss changed priority from minor to major
commented

@robertwb
Copy link
Contributor Author

robertwb commented Mar 8, 2009

scoder commented

Test added as -T156.

@robertwb
Copy link
Contributor Author

@robertwb changed owner from somebody to robertwb
commented

@robertwb
Copy link
Contributor Author

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

http://hg.cython.org/cython-devel/rev/51b79d9aca35

@robertwb robertwb added this to the 0.11.1 milestone Aug 16, 2016
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