File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -701,6 +701,14 @@ class D(C[T]):
701
701
self .assertEqual (D .x , 'from derived x' )
702
702
self .assertEqual (D [str ].z , 'from derived z' )
703
703
704
+ def test_abc_registry_kept (self ):
705
+ T = TypeVar ('T' )
706
+ class C (Generic [T ]): ...
707
+ C .register (int )
708
+ self .assertIsInstance (1 , C )
709
+ C [int ]
710
+ self .assertIsInstance (1 , C )
711
+
704
712
def test_false_subclasses (self ):
705
713
class MyMapping (MutableMapping [str , str ]): pass
706
714
self .assertNotIsInstance ({}, MyMapping )
Original file line number Diff line number Diff line change @@ -1160,7 +1160,10 @@ def __copy__(self):
1160
1160
1161
1161
def __setattr__ (self , attr , value ):
1162
1162
# We consider all the subscripted genrics as proxies for original class
1163
- if attr .startswith ('__' ) and attr .endswith ('__' ):
1163
+ if (
1164
+ attr .startswith ('__' ) and attr .endswith ('__' ) or
1165
+ attr .startswith ('_abc_' )
1166
+ ):
1164
1167
super (GenericMeta , self ).__setattr__ (attr , value )
1165
1168
else :
1166
1169
super (GenericMeta , _gorg (self )).__setattr__ (attr , value )
You can’t perform that action at this time.
0 commit comments