Bug 24568 - UnicodeDecodeError raised in CommandPrinter's _print_MSG method
Summary: UnicodeDecodeError raised in CommandPrinter's _print_MSG method
Status: RESOLVED FIXED
Alias: None
Product: papyon
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All All
: medium blocker
Assignee: Louis-Francis Ratté-Boulianne
QA Contact: Telepathy bugs list
URL:
Whiteboard:
Keywords:
: 20084 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-10-16 03:42 UTC by Korey Lu
Modified: 2010-03-12 18:03 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Korey Lu 2009-10-16 03:42:28 UTC
Traceback (most recent call last):
  File "/tmp/papyon-0.4.2/papyon/transport.py", line 337, in __on_received
    logger.debug('<<< ' + unicode(cmd))
  File "/tmp/papyon-0.4.2/papyon/msnp/command.py", line 230, in __unicode__
    return unicode(CommandPrinter(self))
  File "/tmp/papyon-0.4.2/papyon/msnp/command.py", line 36, in __unicode__
    return printer()
  File "/tmp/papyon-0.4.2/papyon/msnp/command.py", line 68, in _print_MSG
    result += payload
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 211: ordinal not in range(128)

That is caused by my non-ascii MSN nickname.  As a result, Empathy cannot connect to MSN and always reporting `network error'.

In command.py:

    def _print_MSG(self):
        command = self.command
        result = self._print_default_header()
        
        if command.payload is not None:
            payload = repr(Message(None, str(command.payload)))
            length = len(payload)
            if length > 0:
                result += ' ' + str(length) + '\r\n'
                result += payload
        return result

In my case, payload is an UTF-8 encoded string (<type 'str'>), while result is an unicode string (<type 'unicode'>).

My repr(command.payload) is (note the UTF-8 charset and non-ascii nickname):

'MIME-Version: 1.0\r\nContent-Type: text/x-msmsgsprofile; charset=UTF-8\r\nLoginTime: 1255689033\r\nEmailEnabled: 1\r\nMemberIdHigh: 425982\r\nMemberIdLow: -1605703603\r\nlang_preference: 2052\r\npreferredEmail: \r\ncountry: CN\r\nPostalCode: \r\nGender: \r\nKid: 0\r\nAge: \r\nBDayPre: \r\nBirthday: \r\nWallet: \r\nFlags: 1073742915\r\nsid: 72652\r\n\r\nClientIP: 124.207.41.123\r\nClientPort: 0\r\nABCHMigrated: 1\r\nNickname: \xe9\x98\x94\r\nMPOPEnabled: 0\r\n\r\n'

I don't know if everyone gets UTF-8 encoded response from the MSN server, but for me, this trick works well:

    payload = repr(Message(None, str(command.payload))).decode('utf-8')
Comment 1 Jonny Lamb 2010-03-12 17:04:30 UTC
Fixed as of 0.4.5.
Comment 2 Jonny Lamb 2010-03-12 18:02:57 UTC
*** Bug 20084 has been marked as a duplicate of this bug. ***
Comment 3 Jonny Lamb 2010-03-12 18:03:29 UTC
(In reply to comment #1)
> Fixed as of 0.4.5.

I mean 0.4.2. I can't read "git tag --contains" properly.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.