Skip to content

Method "annotate_exception", may fail when data value is binary #523

@brunsgaard

Description

@brunsgaard

From client.py we have:

2528     def annotate_exception(self, exception, number, command):
2529         cmd = unicode(' ').join(imap(unicode, command))
2530         msg = unicode('Command # %d (%s) of pipeline caused error: %s') % (
2531             number, cmd, unicode(exception.args[0]))
2532         exception.args = (msg,) + exception.args[1:]

the imap'ing at line 2529 may throw an UnicodeDecodeError when command holds binary data.

The following is the ouput of print(command) before line 2529,

('ZADD', 'test.sms.normal:delayed', 915148800, '\x08\xe3\xb6\x12\x12\x1b\xc3\x85ello World, %1, --MYTAG--\x1aZ\x08\x01\x10\x82\x04\x18\xf1\xf7\' \xae\x02(\xd0\x052?\t\xaeG\xe1z\x14\xae\xf3?\x12\x03CAD\x1a\x03P01"\x13Example charged SMS*\x04SC122\x0fExample service:\x03foo:\x03bar"\x0f123456789012345(\x80\xa0\xb0\xb4\x032\t--MYTAG--2\x02%1:\x041234@\x01H\x80\xa3\x05P\x00X\x02b\x06\x05\x04\x0b\x84#\xf0j\x17payload encoded as b64\np\x01x\xe2\xb6\x12\x82\x01\x01A')

and it throws the follwoing exception

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 1: ordinal not in range(128)

I think using .decode('unicode_escape') will solve the problem, I will test it a little and make a PR, sunday ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions