Blame SOURCES/jabberpy-python3.patch

42adf4
diff --git jabberpy-0.5-0/jabber/__init__.py jabberpy-0.5-0/jabber/__init__.py
42adf4
index ba26086..8d134bd 100644
42adf4
--- jabberpy-0.5-0/jabber/__init__.py
42adf4
+++ jabberpy-0.5-0/jabber/__init__.py
42adf4
@@ -1,6 +1,10 @@
42adf4
-__all__ = []
42adf4
+import sys
42adf4
+if sys.version_info[0] == 3:
42adf4
+    from . import jabber
42adf4
+else:
42adf4
+    import jabber
42adf4
 
42adf4
-import jabber
42adf4
+__all__ = []
42adf4
 
42adf4
 for __s in dir(jabber):
42adf4
     __val = getattr(jabber, __s)
42adf4
diff --git jabberpy-0.5-0/jabber/debug.py jabberpy-0.5-0/jabber/debug.py
42adf4
index 4615697..b9ee00d 100644
42adf4
--- jabberpy-0.5-0/jabber/debug.py
42adf4
+++ jabberpy-0.5-0/jabber/debug.py
42adf4
@@ -41,9 +41,13 @@ in this code
42adf4
 
42adf4
 import sys
42adf4
 import time
42adf4
-from string import join
42adf4
 
42adf4
-import types
42adf4
+if sys.version_info[0] == 3:
42adf4
+    StringType = (str, bytes)
42adf4
+    UnicodeType = str
42adf4
+else:
42adf4
+    StringType = basestring
42adf4
+    UnicodeType = unicode
42adf4
 
42adf4
 
42adf4
 debug_flags = []
42adf4
@@ -164,10 +168,10 @@ class Debug:
42adf4
                   ):
42adf4
 
42adf4
         if type(active_flags) not in [type([]), type(())]:
42adf4
-            print  '***' 
42adf4
-            print  '*** Invalid or oldformat debug param given: %s' % active_flags
42adf4
-            print  '*** please correct your param, should be of [] type!'
42adf4
-            print  '*** Due to this, full debuging is enabled'
42adf4
+            print('***')
42adf4
+            print('*** Invalid or oldformat debug param given: %s' % active_flags)
42adf4
+            print('*** please correct your param, should be of [] type!')
42adf4
+            print('*** Due to this, full debuging is enabled')
42adf4
             active_flags=[DBG_ALWAYS]
42adf4
 
42adf4
         if welcome == -1:
42adf4
@@ -182,7 +186,7 @@ class Debug:
42adf4
                 try:
42adf4
                     self._fh = open(log_file,'w')
42adf4
                 except:
42adf4
-                    print 'ERROR: can open %s for writing'
42adf4
+                    print('ERROR: can open %s for writing')
42adf4
                     sys.exit(0)
42adf4
             else: ## assume its a stream type object
42adf4
                 self._fh = log_file
42adf4
@@ -190,8 +194,7 @@ class Debug:
42adf4
             self._fh = sys.stdout
42adf4
          
42adf4
         if time_stamp not in (0,1,2):
42adf4
-            msg2 = '%s' % time_stamp
42adf4
-            raise 'Invalid time_stamp param', msg2
42adf4
+            raise Exception('Invalid time_stamp param: %s' % time_stamp)
42adf4
         self.prefix = prefix
42adf4
         self.sufix = sufix
42adf4
         self.time_stamp = time_stamp
42adf4
@@ -214,8 +217,7 @@ class Debug:
42adf4
         if type(flag_show) in (type(''), type(None)):
42adf4
             self.flag_show = flag_show
42adf4
         else:
42adf4
-            msg2 = '%s' % type(flag_show )
42adf4
-            raise 'Invalid type for flag_show!', msg2
42adf4
+            raise Exception('Invalid type for flag_show: %s' % type(flag_show))
42adf4
 
42adf4
 
42adf4
         
42adf4
@@ -271,7 +273,7 @@ class Debug:
42adf4
                 # dont print "None", just show the separator
42adf4
                 output = '%s %s' % ( output, self.flag_show )
42adf4
 
42adf4
-        if type(msg)==type(u'') and self.encoding:
42adf4
+        if isinstance(msg, UnicodeType) and self.encoding:
42adf4
             msg=msg.encode(self.encoding, 'replace')
42adf4
 
42adf4
         output = '%s%s%s' % ( output, msg, suf )
42adf4
@@ -321,11 +323,11 @@ class Debug:
42adf4
         if not active_flags:
42adf4
             #no debuging at all
42adf4
             self.active = []
42adf4
-        elif type( active_flags ) in ( types.TupleType, types.ListType ):
42adf4
+        elif isinstance(active_flags, (tuple, list)):
42adf4
             flags = self._as_one_list( active_flags )
42adf4
             for t in flags:
42adf4
                 if t not in debug_flags:
42adf4
-                    print 'Invalid debugflag given', t
42adf4
+                    print('Invalid debugflag given', t)
42adf4
                 else:
42adf4
                     ok_flags.append( t )
42adf4
                 
42adf4
@@ -360,7 +362,7 @@ class Debug:
42adf4
         
42adf4
         This code organises lst and remves dupes
42adf4
         """
42adf4
-        if type( items ) <> type( [] ) and type( items ) <> type( () ):
42adf4
+        if not isinstance(items, (tuple, list)):
42adf4
             return [ items ]
42adf4
         r = []
42adf4
         for l in items:
42adf4
@@ -377,9 +379,8 @@ class Debug:
42adf4
     
42adf4
     def _append_unique_str( self, lst, item ):
42adf4
         """filter out any dupes."""
42adf4
-        if type(item) <> type(''):
42adf4
-            msg2 = '%s' % item
42adf4
-            raise 'Invalid item type (should be string)',msg2
42adf4
+        if not isinstance(item, StringType):
42adf4
+            raise Exception('Invalid item type (should be string): %s' % type(item))
42adf4
         if item not in lst:
42adf4
             lst.append( item )
42adf4
         return lst
42adf4
@@ -389,9 +390,8 @@ class Debug:
42adf4
         'verify that flag is defined.'
42adf4
         if flags:
42adf4
             for f in self._as_one_list( flags ):
42adf4
-                if not f in debug_flags:
42adf4
-                    msg2 = '%s' % f
42adf4
-                    raise 'Invalid debugflag given', msg2
42adf4
+                if f not in debug_flags:
42adf4
+                    raise Exception('Invalid debugflag given: %s' % f)
42adf4
 
42adf4
     def _remove_dupe_flags( self ):
42adf4
         """
42adf4
diff --git jabberpy-0.5-0/jabber/jabber.py jabberpy-0.5-0/jabber/jabber.py
42adf4
index ab9d9b3..c6c97c7 100644
42adf4
--- jabberpy-0.5-0/jabber/jabber.py
42adf4
+++ jabberpy-0.5-0/jabber/jabber.py
42adf4
@@ -64,17 +64,23 @@ An example of usage for a simple client would be ( only psuedo code !)
42adf4
 
42adf4
 # $Id: jabber.py,v 1.58 2004/01/18 05:27:10 snakeru Exp $
42adf4
 
42adf4
-import xmlstream
42adf4
 import time
42adf4
 import hashlib
42adf4
+import sys
42adf4
+
42adf4
+if sys.version_info[0] == 3:
42adf4
+    from . import xmlstream
42adf4
+    StringType = (str, bytes)
42adf4
+    UnicodeType = str
42adf4
+else:
42adf4
+    import xmlstream
42adf4
+    StringType = basestring
42adf4
+    UnicodeType = unicode
42adf4
 
42adf4
 debug=xmlstream.debug
42adf4
 
42adf4
 VERSION = xmlstream.VERSION
42adf4
 
42adf4
-False = 0;
42adf4
-True  = 1;
42adf4
-
42adf4
 timeout = 300
42adf4
 
42adf4
 DBG_INIT, DBG_ALWAYS = debug.DBG_INIT, debug.DBG_ALWAYS
42adf4
@@ -179,14 +185,14 @@ RS_EXT_PENDING  = 0
42adf4
 def ustr(what):
42adf4
     """If sending object is already a unicode str, just
42adf4
        return it, otherwise convert it using xmlstream.ENCODING"""
42adf4
-    if type(what) == type(u''):
42adf4
+    if isinstance(what, UnicodeType):
42adf4
         r = what
42adf4
     else:
42adf4
         try: r = what.__str__()
42adf4
         except AttributeError: r = str(what)
42adf4
         # make sure __str__() didnt return a unicode
42adf4
-        if type(r) <> type(u''):
42adf4
-            r = unicode(r,xmlstream.ENCODING,'replace')
42adf4
+        if not isinstance(r, UnicodeType):
42adf4
+            r = UnicodeType(r,xmlstream.ENCODING,'replace')
42adf4
     return r
42adf4
 xmlstream.ustr = ustr
42adf4
 
42adf4
@@ -218,17 +224,17 @@ class Connection(xmlstream.Client):
42adf4
 
42adf4
     def setMessageHandler(self, func, type='', chainOutput=False):
42adf4
         """Back compartibility method"""
42adf4
-        print "WARNING! setMessageHandler(...) method is obsolette, use registerHandler('message',...) instead."
42adf4
+        print("WARNING! setMessageHandler(...) method is obsolette, use registerHandler('message',...) instead.")
42adf4
         return self.registerHandler('message', func, type, chained=chainOutput)
42adf4
 
42adf4
     def setPresenceHandler(self, func, type='', chainOutput=False):
42adf4
         """Back compartibility method"""
42adf4
-        print "WARNING! setPresenceHandler(...) method is obsolette, use registerHandler('presence',...) instead."
42adf4
+        print("WARNING! setPresenceHandler(...) method is obsolette, use registerHandler('presence',...) instead.")
42adf4
         return self.registerHandler('presence', func, type, chained=chainOutput)
42adf4
 
42adf4
     def setIqHandler(self, func, type='', ns=''):
42adf4
         """Back compartibility method"""
42adf4
-        print "WARNING! setIqHandler(...) method is obsolette, use registerHandler('iq',...) instead."
42adf4
+        print("WARNING! setIqHandler(...) method is obsolette, use registerHandler('iq',...) instead.")
42adf4
         return self.registerHandler('iq', func, type, ns)
42adf4
 
42adf4
     def header(self):
42adf4
@@ -248,7 +254,7 @@ class Connection(xmlstream.Client):
42adf4
 
42adf4
     def _expectedIqHandler(self, conn, iq_obj):
42adf4
         if iq_obj.getAttr('id') and \
42adf4
-           self._expected.has_key(iq_obj.getAttr('id')):
42adf4
+           iq_obj.getAttr('id') in self._expected:
42adf4
             self._expected[iq_obj.getAttr('id')] = iq_obj
42adf4
             raise NodeProcessed('No need for further Iq processing.')
42adf4
 
42adf4
@@ -257,7 +263,7 @@ class Connection(xmlstream.Client):
42adf4
            Builds the relevant jabber.py object and dispatches it
42adf4
            to a relevant function or callback."""
42adf4
         name=stanza.getName()
42adf4
-        if not self.handlers.has_key(name):
42adf4
+        if name not in self.handlers:
42adf4
             self.DEBUG("whats a tag -> " + name,DBG_NODE_UNKNOWN)
42adf4
             name='unknown'
42adf4
         else:
42adf4
@@ -274,9 +280,9 @@ class Connection(xmlstream.Client):
42adf4
         self.DEBUG("dispatch called for: name->%s ns->%s"%(name,ns),DBG_DISPATCH)
42adf4
 
42adf4
         typns=typ+ns
42adf4
-        if not self.handlers[name].has_key(ns): ns=''
42adf4
-        if not self.handlers[name].has_key(typ): typ=''
42adf4
-        if not self.handlers[name].has_key(typns): typns=''
42adf4
+        if ns not in self.handlers[name]: ns=''
42adf4
+        if typ not in self.handlers[name]: typ=''
42adf4
+        if typns not in self.handlers[name]: typns=''
42adf4
 
42adf4
         chain=[]
42adf4
         for key in ['default',typ,ns,typns]: # we will use all handlers: from very common to very particular
42adf4
@@ -337,7 +343,7 @@ class Connection(xmlstream.Client):
42adf4
            have lower priority that common handlers.
42adf4
         """
42adf4
         if not type and not ns: type='default'
42adf4
-        if not self.handlers[name].has_key(type+ns): self.handlers[name][type+ns]=[]
42adf4
+        if type+ns not in self.handlers[name]: self.handlers[name][type+ns]=[]
42adf4
         if makefirst: self.handlers[name][type+ns].insert({'chain':chained,'func':handler,'system':system})
42adf4
         else: self.handlers[name][type+ns].append({'chain':chained,'func':handler,'system':system})
42adf4
 
42adf4
@@ -525,16 +531,23 @@ class Client(Connection):
42adf4
             token = auth_ret_query.getTag('token').getData()
42adf4
             seq = auth_ret_query.getTag('sequence').getData()
42adf4
             self.DEBUG("zero-k authentication supported",(DBG_INIT,DBG_NODE_IQ))
42adf4
-            hash = hashlib.new('sha1', hashlib.new('sha1', passwd).hexdigest()+token).hexdigest()
42adf4
-            for foo in xrange(int(seq)): hash = hashlib.new('sha1', hash).hexdigest()
42adf4
+            # Unicode-objects must be encoded before hashing
42adf4
+            if isinstance(passwd, UnicodeType):
42adf4
+                pass_enc = passwd.encode('utf-8')
42adf4
+            else:
42adf4
+                pass_enc = passwd
42adf4
+            hash = hashlib.new('sha1', hashlib.new('sha1', pass_enc).hexdigest()+token).hexdigest()
42adf4
+            for foo in range(int(seq)): hash = hashlib.new('sha1', hash).hexdigest()
42adf4
             q.insertTag('hash').insertData(hash)
42adf4
 
42adf4
         elif auth_ret_query.getTag('digest'):
42adf4
 
42adf4
             self.DEBUG("digest authentication supported",(DBG_INIT,DBG_NODE_IQ))
42adf4
             digest = q.insertTag('digest')
42adf4
-            digest.insertData(hashlib.new('sha1',
42adf4
-                self.getIncomingID() + passwd).hexdigest() )
42adf4
+            idp = self.getIncomingID() + passwd
42adf4
+            if isinstance(idp, UnicodeType):
42adf4
+                idp = idp.encode('uft-8')
42adf4
+            digest.insertData(hashlib.new('sha1', idp).hexdigest() )
42adf4
         else:
42adf4
             self.DEBUG("plain text authentication supported",(DBG_INIT,DBG_NODE_IQ))
42adf4
             q.insertTag('password').insertData(passwd)
42adf4
@@ -729,7 +742,7 @@ class Protocol(xmlstream.Node):
42adf4
 
42adf4
     def asNode(self):
42adf4
         """Back compartibility method"""
42adf4
-        print 'WARNING! "asNode()" method is obsolette, use Protocol object as Node object instead.'
42adf4
+        print('WARNING! "asNode()" method is obsolette, use Protocol object as Node object instead.')
42adf4
         return self
42adf4
 
42adf4
     def getError(self):
42adf4
@@ -822,7 +835,7 @@ class Protocol(xmlstream.Node):
42adf4
            XML document"""
42adf4
         x = self.setX(namespace)
42adf4
 
42adf4
-        if type(payload) == type('') or type(payload) == type(u''):
42adf4
+        if isinstance(payload, StringType):
42adf4
                 payload = xmlstream.NodeBuilder(payload).getDom()
42adf4
 
42adf4
         x.kids = [] # should be a method for this realy
42adf4
@@ -961,7 +974,7 @@ class Message(Protocol):
42adf4
         return m
42adf4
 
42adf4
     def build_reply(self, reply_txt=''):
42adf4
-        print "WARNING: build_reply method is obsolette. Use buildReply instead."
42adf4
+        print("WARNING: build_reply method is obsolette. Use buildReply instead.")
42adf4
         return self.buildReply(reply_txt)
42adf4
 
42adf4
 #############################################################################
42adf4
@@ -1059,7 +1072,7 @@ class Iq(Protocol):
42adf4
         if q is None:
42adf4
             q = self.insertTag('query')
42adf4
 
42adf4
-        if type(payload) == type('') or type(payload) == type(u''):
42adf4
+        if isinstance(payload, StringType):
42adf4
                 payload = xmlstream.NodeBuilder(payload).getDom()
42adf4
 
42adf4
         if not add: q.kids = []
42adf4
@@ -1138,7 +1151,7 @@ class Roster:
42adf4
     def getStatus(self, jid): ## extended
42adf4
         """Returns the 'status' value for a Roster item with the given jid."""
42adf4
         jid = ustr(jid)
42adf4
-        if self._data.has_key(jid):
42adf4
+        if jid in self._data:
42adf4
             return self._data[jid]['status']
42adf4
         return None
42adf4
 
42adf4
@@ -1146,7 +1159,7 @@ class Roster:
42adf4
     def getShow(self, jid):   ## extended
42adf4
         """Returns the 'show' value for a Roster item with the given jid."""
42adf4
         jid = ustr(jid)
42adf4
-        if self._data.has_key(jid):
42adf4
+        if jid in self._data:
42adf4
             return self._data[jid]['show']
42adf4
         return None
42adf4
 
42adf4
@@ -1155,7 +1168,7 @@ class Roster:
42adf4
         """Returns the 'online' status for a Roster item with the given jid.
42adf4
            """
42adf4
         jid = ustr(jid)
42adf4
-        if self._data.has_key(jid):
42adf4
+        if jid in self._data:
42adf4
             return self._data[jid]['online']
42adf4
         return None
42adf4
 
42adf4
@@ -1164,7 +1177,7 @@ class Roster:
42adf4
         """Returns the 'subscription' status for a Roster item with the given
42adf4
            jid."""
42adf4
         jid = ustr(jid)
42adf4
-        if self._data.has_key(jid):
42adf4
+        if jid in self._data:
42adf4
             return self._data[jid]['sub']
42adf4
         return None
42adf4
 
42adf4
@@ -1172,7 +1185,7 @@ class Roster:
42adf4
     def getName(self,jid):
42adf4
         """Returns the 'name' for a Roster item with the given jid."""
42adf4
         jid = ustr(jid)
42adf4
-        if self._data.has_key(jid):
42adf4
+        if jid in self._data:
42adf4
             return self._data[jid]['name']
42adf4
         return None
42adf4
 
42adf4
@@ -1181,7 +1194,7 @@ class Roster:
42adf4
         """ Returns the lsit of groups associated with the given roster item.
42adf4
         """
42adf4
         jid = ustr(jid)
42adf4
-        if self._data.has_key(jid):
42adf4
+        if jid in self._data:
42adf4
             return self._data[jid]['groups']
42adf4
         return None
42adf4
 
42adf4
@@ -1189,7 +1202,7 @@ class Roster:
42adf4
     def getAsk(self,jid):
42adf4
         """Returns the 'ask' status for a Roster item with the given jid."""
42adf4
         jid = ustr(jid)
42adf4
-        if self._data.has_key(jid):
42adf4
+        if jid in self._data:
42adf4
             return self._data[jid]['ask']
42adf4
         return None
42adf4
 
42adf4
@@ -1233,7 +1246,7 @@ class Roster:
42adf4
         jid = ustr(jid) # just in case
42adf4
         online = 'offline'
42adf4
         if ask: online = 'pending'
42adf4
-        if self._data.has_key(jid): # update it
42adf4
+        if jid in self._data: # update it
42adf4
             self._data[jid]['name'] = name
42adf4
             self._data[jid]['groups'] = groups
42adf4
             self._data[jid]['ask'] = ask
42adf4
@@ -1255,13 +1268,13 @@ class Roster:
42adf4
     def _setOnline(self,jid,val):
42adf4
         """Used internally - private"""
42adf4
         jid = ustr(jid)
42adf4
-        if self._data.has_key(jid):
42adf4
+        if jid in self._data:
42adf4
             self._data[jid]['online'] = val
42adf4
             if self._listener != None:
42adf4
                 self._listener("update", jid, {'online' : val})
42adf4
         else:                      ## fall back
42adf4
             jid_basic = JID(jid).getStripped()
42adf4
-            if self._data.has_key(jid_basic):
42adf4
+            if jid_basic in self._data:
42adf4
                 self._data[jid_basic]['online'] = val
42adf4
                 if self._listener != None:
42adf4
                     self._listener("update", jid_basic, {'online' : val})
42adf4
@@ -1270,13 +1283,13 @@ class Roster:
42adf4
     def _setShow(self,jid,val):
42adf4
         """Used internally - private"""
42adf4
         jid = ustr(jid)
42adf4
-        if self._data.has_key(jid):
42adf4
+        if jid in self._data:
42adf4
             self._data[jid]['show'] = val
42adf4
             if self._listener != None:
42adf4
                 self._listener("update", jid, {'show' : val})
42adf4
         else:                      ## fall back
42adf4
             jid_basic = JID(jid).getStripped()
42adf4
-            if self._data.has_key(jid_basic):
42adf4
+            if jid_basic in self._data:
42adf4
                 self._data[jid_basic]['show'] = val
42adf4
                 if self._listener != None:
42adf4
                     self._listener("update", jid_basic, {'show' : val})
42adf4
@@ -1285,13 +1298,13 @@ class Roster:
42adf4
     def _setStatus(self,jid,val):
42adf4
         """Used internally - private"""
42adf4
         jid = ustr(jid)
42adf4
-        if self._data.has_key(jid):
42adf4
+        if jid in self._data:
42adf4
             self._data[jid]['status'] = val
42adf4
             if self._listener != None:
42adf4
                 self._listener("update", jid, {'status' : val})
42adf4
         else:                      ## fall back
42adf4
             jid_basic = JID(jid).getStripped()
42adf4
-            if self._data.has_key(jid_basic):
42adf4
+            if jid_basic in self._data:
42adf4
                 self._data[jid_basic]['status'] = val
42adf4
                 if self._listener != None:
42adf4
                     self._listener("update", jid_basic, {'status' : val})
42adf4
@@ -1299,7 +1312,7 @@ class Roster:
42adf4
 
42adf4
     def _remove(self,jid):
42adf4
         """Used internally - private"""
42adf4
-        if self._data.has_key(jid):
42adf4
+        if jid in self._data:
42adf4
             del self._data[jid]
42adf4
             if self._listener != None:
42adf4
                 self._listener("remove", jid, {})
42adf4
@@ -1397,8 +1410,11 @@ class Component(Connection):
42adf4
 
42adf4
     def auth(self,secret):
42adf4
         """will disconnect on failure"""
42adf4
+        idp = self.getIncomingID() + secret
42adf4
+        if isinstance(idp, UnicodeType):
42adf4
+            idp = idp.encode('uft-8')
42adf4
         self.send( u"<handshake id='1'>%s</handshake>"
42adf4
-                   % hashlib.new('sha1', self.getIncomingID() + secret ).hexdigest()
42adf4
+                   % hashlib.new('sha1', idp).hexdigest()
42adf4
                   )
42adf4
         while not self._auth_OK:
42adf4
             self.DEBUG("waiting on handshake")
42adf4
diff --git jabberpy-0.5-0/jabber/xmlstream.py jabberpy-0.5-0/jabber/xmlstream.py
42adf4
index e8fdcab..7e72708 100644
42adf4
--- jabberpy-0.5-0/jabber/xmlstream.py
42adf4
+++ jabberpy-0.5-0/jabber/xmlstream.py
42adf4
@@ -34,14 +34,21 @@ import time, sys, re, socket
42adf4
 from select import select
42adf4
 from base64 import encodestring
42adf4
 import xml.parsers.expat
42adf4
-import debug
42adf4
+
42adf4
+if sys.version_info[0] == 3:
42adf4
+    from . import debug
42adf4
+    UnicodeType = str
42adf4
+    BytesType = bytes
42adf4
+else:
42adf4
+    BytesType = str
42adf4
+    UnicodeType = unicode
42adf4
+    import debug
42adf4
+
42adf4
+
42adf4
 _debug=debug
42adf4
 
42adf4
 VERSION = "0.5"
42adf4
 
42adf4
-False = 0
42adf4
-True  = 1
42adf4
-
42adf4
 TCP     = 1
42adf4
 STDIO   = 0
42adf4
 TCP_SSL = 2
42adf4
@@ -83,7 +90,7 @@ class Node:
42adf4
     """A simple XML DOM like class"""
42adf4
     def __init__(self, tag=None, parent=None, attrs={}, payload=[], node=None):
42adf4
         if node:
42adf4
-            if type(node)<>type(self): node=NodeBuilder(node).getDom()
42adf4
+            if type(node) != type(self): node=NodeBuilder(node).getDom()
42adf4
             self.name,self.namespace,self.attrs,self.data,self.kids,self.parent = \
42adf4
                 node.name,node.namespace,node.attrs,node.data,node.kids,node.parent
42adf4
         else:
42adf4
@@ -244,7 +251,8 @@ class NodeBuilder:
42adf4
         self.__depth = 0
42adf4
         self._dispatch_depth = 1
42adf4
 
42adf4
-        if data: self._parser.Parse(data,1)
42adf4
+        if data:
42adf4
+            self._parser.Parse(data.__str__(), 1)
42adf4
 
42adf4
     def unknown_starttag(self, tag, attrs):
42adf4
         """XML Parser callback"""
42adf4
@@ -258,7 +266,7 @@ class NodeBuilder:
42adf4
             self._ptr.kids.append(Node(tag=tag,parent=self._ptr,attrs=attrs))
42adf4
             self._ptr = self._ptr.kids[-1]
42adf4
         else:                           ## it the stream tag:
42adf4
-            if attrs.has_key('id'):
42adf4
+            if 'id' in attrs:
42adf4
                 self._incomingID = attrs['id']
42adf4
         self.last_is_data = False
42adf4
 
42adf4
@@ -322,7 +330,7 @@ class Stream(NodeBuilder):
42adf4
                 try:
42adf4
                     self._logFH = open(log,'w')
42adf4
                 except:
42adf4
-                    print "ERROR: can open %s for writing" % log
42adf4
+                    print("ERROR: can open %s for writing" % log)
42adf4
                     sys.exit(0)
42adf4
             else: ## assume its a stream type object
42adf4
                 self._logFH = log
42adf4
@@ -361,9 +369,9 @@ class Stream(NodeBuilder):
42adf4
            If supplied data is not unicode string, ENCODING
42adf4
            is used for convertion. Avoid this!
42adf4
            Always send your data as a unicode string."""
42adf4
-        if type(raw_data) == type(''):
42adf4
+        if isinstance(raw_data, BytesType):
42adf4
             self.DEBUG('Non-utf-8 string "%s" passed to Stream.write! Treating it as %s encoded.'%(raw_data,ENCODING))
42adf4
-            raw_data = unicode(raw_data,ENCODING)
42adf4
+            raw_data = UnicodeType(raw_data,ENCODING)
42adf4
         data_out = raw_data.encode('utf-8')
42adf4
         try:
42adf4
             self._write(data_out)
42adf4
@@ -469,7 +477,7 @@ class Client(Stream):
42adf4
             af, socktype, proto, canonname, sa = r
42adf4
             try:
42adf4
                 self._sock = socket.socket(af, socktype, proto)
42adf4
-            except socket.error, msg:
42adf4
+            except socket.error:
42adf4
                 self._sock = None
42adf4
                 continue
42adf4
             try:
42adf4
@@ -477,7 +485,8 @@ class Client(Stream):
42adf4
                     self._sock.connect((self._proxy['host'], self._proxy['port']))
42adf4
                 else:
42adf4
                     self._sock.connect((self._hostIP, self._port))
42adf4
-            except socket.error, e:
42adf4
+            except socket.error:
42adf4
+                e = sys.exc_info()[1]
42adf4
                 self._sock.close()
42adf4
                 self._sock = None
42adf4
                 self.DEBUG("socket error: "+str(e),DBG_CONN_ERROR)
42adf4
@@ -501,7 +510,7 @@ class Client(Stream):
42adf4
 
42adf4
         if self._proxy:
42adf4
             self.DEBUG("Proxy connected",DBG_INIT)
42adf4
-            if self._proxy.has_key('type'): type = self._proxy['type'].upper()
42adf4
+            if 'type' in self._proxy: type = self._proxy['type'].upper()
42adf4
             else: type = 'CONNECT'
42adf4
             connector = []
42adf4
             if type == 'CONNECT':
42adf4
@@ -515,7 +524,7 @@ class Client(Stream):
42adf4
             connector.append('Pragma: no-cache')
42adf4
             connector.append('Host: %s:%s'%(self._hostIP,self._port))
42adf4
             connector.append('User-Agent: Jabberpy/'+VERSION)
42adf4
-            if self._proxy.has_key('user') and self._proxy.has_key('password'):
42adf4
+            if 'user' in self._proxy and 'password' in self._proxy:
42adf4
                 credentials = '%s:%s'%(self._proxy['user'],self._proxy['password'])
42adf4
                 credentials = encodestring(credentials).strip()
42adf4
                 connector.append('Proxy-Authorization: Basic '+credentials)
42adf4
@@ -526,7 +535,7 @@ class Client(Stream):
42adf4
             self._read , self._write = bak
42adf4
             try: proto,code,desc=reply.split('\n')[0].split(' ',2)
42adf4
             except: raise error('Invalid proxy reply')
42adf4
-            if code<>'200': raise error('Invalid proxy reply: %s %s %s'%(proto,code,desc))
42adf4
+            if code != '200': raise error('Invalid proxy reply: %s %s %s'%(proto,code,desc))
42adf4
             while reply.find('\n\n') == -1: reply += self.read().replace('\r','')
42adf4
 
42adf4
         self.DEBUG("Jabber server connected",DBG_INIT)
42adf4
@@ -574,16 +583,16 @@ class Server:
42adf4
 
42adf4
     def serve(self):
42adf4
 
42adf4
-        print 'select-server loop starting'
42adf4
+        print('select-server loop starting')
42adf4
 
42adf4
         while 1:
42adf4
-            print "LOOPING"
42adf4
+            print("LOOPING")
42adf4
             readables, writeables, exceptions = select(self.readsocks,
42adf4
                                                        self.writesocks, [])
42adf4
             for sockobj in readables:
42adf4
                 if sockobj in self. mainsocks:   # for ready input sockets
42adf4
                     newsock, address = sockobj.accept() # accept not block
42adf4
-                    print 'Connect:', address, id(newsock)
42adf4
+                    print('Connect:', address, id(newsock))
42adf4
                     self.readsocks.append(newsock)
42adf4
                     self._makeNewStream(newsock)
42adf4
                     # add to select list, wait
42adf4
@@ -591,7 +600,7 @@ class Server:
42adf4
                     # client socket: read next line
42adf4
                     data = sockobj.recv(1024)
42adf4
                     # recv should not block
42adf4
-                    print '\tgot', data, 'on', id(sockobj)
42adf4
+                    print('\tgot', data, 'on', id(sockobj))
42adf4
                     if not data:        # if closed by the clients
42adf4
                         sockobj.close() # close here and remv from
42adf4
                         self.readsocks.remove(sockobj)
42adf4
diff --git jabberpy-0.5-0/setup.py jabberpy-0.5-0/setup.py
42adf4
index 11f6f81..84c5369 100644
42adf4
--- jabberpy-0.5-0/setup.py
42adf4
+++ jabberpy-0.5-0/setup.py
42adf4
@@ -5,14 +5,14 @@ try:
42adf4
     from distutils.core import setup
42adf4
 except:
42adf4
     if sys.version[0] < 2:
42adf4
-        print "jabber.py requires at least python 2.0"
42adf4
-        print "Setup cannot continue."
42adf4
+        print("jabber.py requires at least python 2.0")
42adf4
+        print("Setup cannot continue.")
42adf4
         sys.exit(1)
42adf4
-    print "You appear not to have the Python distutils modules"
42adf4
-    print "installed. Setup cannot continue."
42adf4
-    print "You can manually install jabberpy by coping the jabber"
42adf4
-    print "directory to your /python-libdir/site-packages"    
42adf4
-    print "directory."
42adf4
+    print("You appear not to have the Python distutils modules")
42adf4
+    print("installed. Setup cannot continue.")
42adf4
+    print("You can manually install jabberpy by coping the jabber")
42adf4
+    print("directory to your /python-libdir/site-packages")
42adf4
+    print("directory.")
42adf4
     sys.exit(1)
42adf4
     
42adf4
 setup(name="jabber.py",