basestring makes the isinstance checks work.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 6 Oct 2012 08:49:00 +0000 (04:49 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 6 Oct 2012 08:49:00 +0000 (04:49 -0400)
irkerd

diff --git a/irkerd b/irkerd
index 76cda615298224b32e3ab1542cde4d7b993b5bb0..34fb33aae496f4402df5013c034090be7fb89c14 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -428,15 +428,15 @@ class Irker:
             else:
                 channels = request['to']
                 message = request['privmsg']
-                if type(channels) not in (type([]), type(""), type(u"")):
+                if not isinstance(channels, (list, basestring)):
                     self.logerr("malformed request - unexpected channel type: %r" % channels)
-                if type(message) not in (type(""), type(u"")):
+                if not isinstance(message, basestring):
                     self.logerr("malformed request - unexpected message type: %r" % message)
                 else:
-                    if type(channels) != type([]):
+                    if not isinstance(channels, list):
                         channels = [channels]
                     for url in channels:
-                        if not type(url) in (type(""), type(u"")): 
+                        if not isinstance(url, basestring):
                             self.logerr("malformed request - URL has unexpected type: %r" % url)
                         else:
                             target = Target(url)