~jameinel/bzr/2.1-all-reconnect-819604

« back to all changes in this revision

Viewing changes to bzrlib/smart/protocol.py

  • Committer: John Arbash Meinel
  • Date: 2012-09-12 08:27:18 UTC
  • Revision ID: john@arbash-meinel.com-20120912082718-rc0056el65dtvpdy
Bring in an AJB patch about Unicode handling with _encode_tuple.

It would seem that at least in some places NoSuchFile gets the unicode path,
which ends up wanting to turn the smart server request into a unicode stream,
which ends up transmitting the 2-byte unicode chars as a regular buffer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
 
63
63
def _encode_tuple(args):
64
64
    """Encode the tuple args to a bytestream."""
65
 
    return '\x01'.join(args) + '\n'
 
65
    joined = '\x01'.join(args) + '\n'
 
66
    if type(joined) is unicode:
 
67
        # XXX: We should fix things so this never happens!  -AJB, 20100304
 
68
        mutter('response args contain unicode, should be only bytes: %r',
 
69
               joined)
 
70
        joined = joined.encode('ascii')
 
71
    return joined
66
72
 
67
73
 
68
74
class Requester(object):