|
@@ -110,7 +110,7 @@ class ImmutableAttr: # Descriptor
|
|
if include_proto:
|
|
if include_proto:
|
|
assert typeconv, 'ImmutableAttr_check2'
|
|
assert typeconv, 'ImmutableAttr_check2'
|
|
if set_none_ok:
|
|
if set_none_ok:
|
|
- assert typeconv and type(dtype) != str, 'ImmutableAttr_check3'
|
|
|
|
|
|
+ assert typeconv and not isinstance(dtype,str), 'ImmutableAttr_check3'
|
|
|
|
|
|
if dtype is None:
|
|
if dtype is None:
|
|
# use instance-defined conversion function for this attribute
|
|
# use instance-defined conversion function for this attribute
|
|
@@ -229,7 +229,7 @@ class MMGenRange(tuple,InitErrors,MMGenObject):
|
|
try:
|
|
try:
|
|
if len(args) == 1:
|
|
if len(args) == 1:
|
|
s = args[0]
|
|
s = args[0]
|
|
- if type(s) == cls:
|
|
|
|
|
|
+ if isinstance(s,cls):
|
|
return s
|
|
return s
|
|
assert isinstance(s,str),'not a string or string subclass'
|
|
assert isinstance(s,str),'not a string or string subclass'
|
|
ss = s.split('-',1)
|
|
ss = s.split('-',1)
|
|
@@ -270,7 +270,7 @@ class Int(int,Hilite,InitErrors):
|
|
color = 'red'
|
|
color = 'red'
|
|
|
|
|
|
def __new__(cls,n,base=10):
|
|
def __new__(cls,n,base=10):
|
|
- if type(n) == cls:
|
|
|
|
|
|
+ if isinstance(n,cls):
|
|
return n
|
|
return n
|
|
try:
|
|
try:
|
|
me = int.__new__(cls,str(n),base)
|
|
me = int.__new__(cls,str(n),base)
|
|
@@ -312,7 +312,7 @@ class HexStr(str,Hilite,InitErrors):
|
|
hexcase = 'lower'
|
|
hexcase = 'lower'
|
|
trunc_ok = False
|
|
trunc_ok = False
|
|
def __new__(cls,s,case=None):
|
|
def __new__(cls,s,case=None):
|
|
- if type(s) == cls:
|
|
|
|
|
|
+ if isinstance(s,cls):
|
|
return s
|
|
return s
|
|
if case == None:
|
|
if case == None:
|
|
case = cls.hexcase
|
|
case = cls.hexcase
|
|
@@ -351,13 +351,13 @@ class MMGenLabel(str,Hilite,InitErrors):
|
|
min_len = 0
|
|
min_len = 0
|
|
max_screen_width = 0 # if != 0, overrides max_len
|
|
max_screen_width = 0 # if != 0, overrides max_len
|
|
desc = 'label'
|
|
desc = 'label'
|
|
- def __new__(cls,s,msg=None):
|
|
|
|
- if type(s) == cls:
|
|
|
|
|
|
+ def __new__(cls,s):
|
|
|
|
+ if isinstance(s,cls):
|
|
return s
|
|
return s
|
|
for k in ( cls.forbidden, cls.allowed ):
|
|
for k in ( cls.forbidden, cls.allowed ):
|
|
- assert type(k) == list
|
|
|
|
|
|
+ assert isinstance(k,list)
|
|
for ch in k:
|
|
for ch in k:
|
|
- assert type(ch) == str and len(ch) == 1
|
|
|
|
|
|
+ assert isinstance(ch,str) and len(ch) == 1
|
|
try:
|
|
try:
|
|
s = s.strip()
|
|
s = s.strip()
|
|
for ch in s:
|
|
for ch in s:
|