stack.append(res)
continue
- assert isinstance(obj, (dict, _ScopeDict)),\
+ assert isinstance(obj, (dict, _ScopeDict)), \
'Accessing member %r on %r' % (pname, obj)
res = obj.get(pname, undefined)
stack.append(res)
def unescapeHTML(s):
if s is None:
return None
- assert type(s) == compat_str
+ assert isinstance(s, compat_str)
return re.sub(
r'&([^&;]+;)', lambda m: _htmlentity_transform(m.group(1)), s)
def write_string(s, out=None, encoding=None):
if out is None:
out = sys.stderr
- assert type(s) == compat_str
+ assert isinstance(s, compat_str)
if sys.platform == 'win32' and encoding is None and hasattr(out, 'fileno'):
if _windows_write_string(s, out):
def parse_age_limit(s):
- if type(s) == int:
- return s if 0 <= s <= 21 else None
+ if not isinstance(s, bool):
+ age = int_or_none(s)
+ if age is not None:
+ return age if 0 <= age <= 21 else None
if not isinstance(s, compat_basestring):
return None
m = re.match(r'^(?P<age>\d{1,2})\+?$', s)