[3.6] bpo-28556: Update to typing: treat subscripted generics as proxies (GH-265) (GH-268)

(cherry picked from commit abb3b8ad94)
(cherry picked from commit 365cb5bb90)
This commit is contained in:
Mariatta 2017-02-24 16:40:50 -08:00 committed by GitHub
parent f28db60179
commit bea9d2f648
2 changed files with 45 additions and 0 deletions

View file

@ -1158,6 +1158,16 @@ class GenericMeta(TypingMeta, abc.ABCMeta):
self.__parameters__, self.__args__, self.__origin__,
self.__extra__, self.__orig_bases__)
def __setattr__(self, attr, value):
# We consider all the subscripted genrics as proxies for original class
if (
attr.startswith('__') and attr.endswith('__') or
attr.startswith('_abc_')
):
super(GenericMeta, self).__setattr__(attr, value)
else:
super(GenericMeta, _gorg(self)).__setattr__(attr, value)
# Prevent checks for Generic to crash when defining Generic.
Generic = None