From 9367bd2379b3f27d06ce386ba73dc5db289be0ae Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Wed, 3 Oct 2012 22:58:04 +0200 Subject: [PATCH] Use isinstance() instead of type() == type() checks. --- irkerd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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) -- 2.26.2