➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Ilya.Kulakov
Recipients Ilya.Kulakov
Date 2017-11-28.22:27:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1511908063.67.0.213398074469.issue32162@psf.upfronthosting.co.za>
In-reply-to
Content
When superclass inherits from Generic, attributes set for a subclass are incorrectly propagated to its superclass.

Without Generic attribute access raises an exception:

    class X:
        def __init_subclass__(cls, **kwargs):
            super().__init_subclass__(**kwargs)
            cls.attr = 42

    class Y(X):
        pass

    Y.attr  # 42
    X.attr  # AttributeError

With Generic it does not:

    import typing

    T = typing.TypeVar('T')

    class X(typing.Generic[T]):
        def __init_subclass__(cls, **kwargs):
            super().__init_subclass__(**kwargs)
            cls.attr = 42

    class Y(X):
        pass

    Y.attr  # 42
    X.attr  # 42
History
Date User Action Args
2017-11-28 22:27:43Ilya.Kulakovsetrecipients: + Ilya.Kulakov
2017-11-28 22:27:43Ilya.Kulakovsetmessageid: <1511908063.67.0.213398074469.issue32162@psf.upfronthosting.co.za>
2017-11-28 22:27:43Ilya.Kulakovlinkissue32162 messages
2017-11-28 22:27:43Ilya.Kulakovcreate