-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
Milestone
Description
When defining a Python class using Cython, the __qualname__ attribute is always set, even on Python 2. When this Cython-defined class is either subclassed or used as metaclass in pure Python code, that new class gets the wrong __qualname__ from Cython.
Examples:
# In Cython
class X(type): pass
# In Python
>>> class Y(X): pass
>>> Y.__qualname__
X
# In Python
>>> class Y(object): __metaclass__ = X
>>> Y.__qualname__
X
As you can see, we get a wrong __qualname__ in both cases. This confuses for example tools like Sphinx, where it produces incorrect output.
Since __qualname__ is useless on Python 2, I suggest to simply not set __qualname__ on Python 2. For Sphinx, not having a __qualname__ is fine, since it will simply use __name__ which is correct.