sasl fails when using unicode jids

[email protected] Tue, 08 Dec 2009 17:48:32 -0000
Newsgroups gmane.comp.python.twisted.bugs
Message-ID <[email protected]>
New submission from sciasbat <[email protected]>:

here is a full stack trace:
{{{
	Traceback (most recent call last):
	  File "/home/packages/python/2.5/python2.5-2.5.2/Modules/pyexpat.c", line 656, in EndElement
	    
	  File "/usr/lib/python2.5/site-packages/twisted/words/xish/domish.py", line 780, in _onEndElement
	    self.ElementEvent(self.currElem)
	  File "/usr/lib/python2.5/site-packages/twisted/words/xish/xmlstream.py", line 106, in onElement
	    self.dispatch(element)
	  File "/usr/lib/python2.5/site-packages/twisted/words/xish/utility.py", line 316, in dispatch
	    callbacklist.callback(obj)
	--- <exception caught here> ---
	  File "/usr/lib/python2.5/site-packages/twisted/words/xish/utility.py", line 106, in callback
	    methodwrapper(*args, **kwargs)
	  File "/usr/lib/python2.5/site-packages/twisted/words/xish/utility.py", line 27, in __call__
	    self.method(*nargs, **nkwargs)
	  File "/usr/lib/python2.5/site-packages/twisted/words/protocols/jabber/sasl.py", line 193, in onChallenge
	    self.sendResponse(self.mechanism.getResponse(challenge))
	  File "/usr/lib/python2.5/site-packages/twisted/words/protocols/jabber/sasl_mechanisms.py", line 100, in getResponse
	    directives['nonce'])
	  File "/usr/lib/python2.5/site-packages/twisted/words/protocols/jabber/sasl_mechanisms.py", line 220, in _gen_response
	    return self._unparse(directives)
	  File "/usr/lib/python2.5/site-packages/twisted/words/protocols/jabber/sasl_mechanisms.py", line 168, in _unparse
	    return ','.join(directive_list)
	exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 13: ordinal not in range(128)
}}}

In my working copy this fix in _unparse works:
{{{
  for name, value in directives.iteritems():
            if isinstance(name, unicode): name = name.encode("utf8")
            if isinstance(value, unicode): value = value.encode("utf8")
}}}

----------
Type     : defect
Component: words
Keywords : sasl
Priority : normal
Nosy     : 
----------
http://twistedmatrix.com/trac/ticket/4161