File tree 2 files changed +5
-1
lines changed
2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -346,7 +346,7 @@ def __instancecheck__(cls, inst):
346
346
except AttributeError :
347
347
return False
348
348
else :
349
- return type (value ) in _const_types [cls ]
349
+ return isinstance (value , _const_types [cls ])
350
350
return type .__instancecheck__ (cls , inst )
351
351
352
352
def _new (cls , * args , ** kwargs ):
Original file line number Diff line number Diff line change @@ -399,6 +399,10 @@ def test_isinstance(self):
399
399
self .assertFalse (isinstance (ast .Constant (), ast .NameConstant ))
400
400
self .assertFalse (isinstance (ast .Constant (), ast .Ellipsis ))
401
401
402
+ class S (str ): pass
403
+ self .assertTrue (isinstance (ast .Constant (S ('42' )), ast .Str ))
404
+ self .assertFalse (isinstance (ast .Constant (S ('42' )), ast .Num ))
405
+
402
406
def test_subclasses (self ):
403
407
class N (ast .Num ):
404
408
def __init__ (self , * args , ** kwargs ):
You can’t perform that action at this time.
0 commit comments