summaryrefslogtreecommitdiff
path: root/sleekxmpp/__init__.py
diff options
context:
space:
mode:
authorNathan Fritz <fritzy@netflint.net>2010-01-08 06:03:02 +0000
committerNathan Fritz <fritzy@netflint.net>2010-01-08 06:03:02 +0000
commita8ff3586d3852fc70b1932a579cf8a28ce920d5c (patch)
tree1422863339fedaf3e0d5039dad0048cf2b677338 /sleekxmpp/__init__.py
parent0af468b435a3c24792f8d70ef802193ff08f26af (diff)
downloadslixmpp-a8ff3586d3852fc70b1932a579cf8a28ce920d5c.tar.gz
slixmpp-a8ff3586d3852fc70b1932a579cf8a28ce920d5c.tar.bz2
slixmpp-a8ff3586d3852fc70b1932a579cf8a28ce920d5c.tar.xz
slixmpp-a8ff3586d3852fc70b1932a579cf8a28ce920d5c.zip
* python 2.6 compatibility
Diffstat (limited to 'sleekxmpp/__init__.py')
-rw-r--r--sleekxmpp/__init__.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/sleekxmpp/__init__.py b/sleekxmpp/__init__.py
index 91dffa04..b81e8a13 100644
--- a/sleekxmpp/__init__.py
+++ b/sleekxmpp/__init__.py
@@ -19,7 +19,7 @@
along with SleekXMPP; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""
-from __future__ import absolute_import
+from __future__ import absolute_import, unicode_literals
from . basexmpp import basexmpp
from xml.etree import cElementTree as ET
from . xmlstream.xmlstream import XMLStream
@@ -201,7 +201,10 @@ class ClientXMPP(basexmpp, XMLStream):
for sasl_mech in sasl_mechs:
self.features.append("sasl:%s" % sasl_mech.text)
if 'sasl:PLAIN' in self.features:
- self.send("""<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>%s</auth>""" % base64.b64encode(b'\x00' + bytes(self.username, 'utf-8') + b'\x00' + bytes(self.password, 'utf-8')).decode('utf-8'))
+ if sys.version_info < (3,0):
+ self.send("""<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>%s</auth>""" % base64.b64encode(b'\x00' + bytes(self.username) + b'\x00' + bytes(self.password)).decode('utf-8'))
+ else:
+ self.send("""<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>%s</auth>""" % base64.b64encode(b'\x00' + bytes(self.username, 'utf-8') + b'\x00' + bytes(self.password, 'utf-8')).decode('utf-8'))
else:
logging.error("No appropriate login method.")
self.disconnect()