• Jason Rhinelander's avatar
    __qualname__ and nested class naming fixes (#1171) · 71178922
    Jason Rhinelander authored
    A few fixes related to how we set `__qualname__` and how we show the
    type name in function signatures:
    
    - `__qualname__` isn't supposed to have the module name at the
    beginning, but we've been putting it there.  This removes it, while
    keeping the `Nested.Class` name chaining.
    
    - print `__module__.__qualname__` rather than `type->tp_name`; the
    latter doesn't work properly for nested classes, so we would get
    `module.B` rather than `module.A.B` for a class `B` with parent `A`.
    This also unifies the Python 3 and PyPy code.  Fixes #1166.
    
    - This now sets a `__qualname__` attribute on the type (as would happen
    in Python 3.3+) for Python <3.3, including PyPy.  While not particularly
    important to have in earlier Python versions, it's useful for us to be
    able to extracted the nested name, which is why `__qualname__` was
    invented in the first place.
    
    - Added tests for the above.
    71178922
test_class.cpp 14.9 KB