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

ERROR: The name '__str__' is reserved for a special method. #1797

Closed
ghost opened this issue Jul 25, 2017 · 1 comment
Closed

ERROR: The name '__str__' is reserved for a special method. #1797

ghost opened this issue Jul 25, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 25, 2017

Good day,

I have a helper class in my package that replaces the str of the input class when used as a decorator. I am in the process of cythonizing the project and I am encountering such error:

[1/1] Cythonizing src/auto_str.py

Error compiling Cython file:
------------------------------------------------------------
...
def auto_str(cls):
    def __str__(self):
   ^
------------------------------------------------------------

src\auto_str.py:2:4: The name '__str__' is reserved for a special method.

A simplified version of the project is attached here.

What would be the best approach for this? I'm pretty new with Cython, apologies if I missed some concepts.

Thank you for your patience and hard work!

Using Cython 0.25.2 with Win 7 x64 and Python 3.4.4

@scoder
Copy link
Contributor

scoder commented Jul 25, 2017

Thanks for the report, you found a bug in Cython.

I think this is because of the function closure, which Cython internally implements as a cdef class. When declaring __str__ in the closure, it is incorrectly checked against a condition that only applies to extension types. I'll see what I can do.

@scoder scoder closed this as completed in fb5e920 Jul 25, 2017
@scoder scoder added this to the 0.26.1 milestone Aug 26, 2017
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