From: Georg Brandl Date: Wed, 3 Oct 2012 20:58:04 +0000 (+0200) Subject: Use isinstance() instead of type() == type() checks. X-Git-Tag: 1.6~4^2~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9367bd2379b3f27d06ce386ba73dc5db289be0ae;p=irker.git Use isinstance() instead of type() == type() checks. --- diff --git a/irkerd b/irkerd index f49535c..b394e62 100755 --- a/irkerd +++ b/irkerd @@ -381,21 +381,21 @@ class Irker: "Perform a JSON relay request." try: request = json.loads(line.strip()) - if type(request) != type({}): + if not isinstance(request, dict): self.logerr("request in tot a JSON dictionary: %r" % request) elif "to" not in request or "privmsg" not in request: self.logerr("malformed reqest - 'to' or 'privmsg' missing: %r" % request) else: channels = request['to'] message = request['privmsg'] - if type(channels) not in (type([]), type(u"")) \ - or type(message) != type(u""): + if not isinstance(channels, (list, unicode)) \ + or not isinstance(message, unicode): self.logerr("malformed request - unexpected types: %r" % request) else: - if type(channels) == type(u""): + if isinstance(channels, unicode): channels = [channels] for url in channels: - if type(url) != type(u""): + if not isinstance(url, unicode): self.logerr("malformed request - unexpected type: %r" % request) else: target = Target(url)