/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transport/ftp/__init__.py

  • Committer: Martin
  • Date: 2017-05-21 18:16:32 UTC
  • mto: (6621.2.22 py3)
  • mto: This revision was merged to the branch mainline in revision 6624.
  • Revision ID: gzlist@googlemail.com-20170521181632-kll0wqnsq8pipfpj
Use BytesIO or StringIO from bzrlib.sixish

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
from __future__ import absolute_import
29
29
 
30
 
from cStringIO import StringIO
31
30
import ftplib
32
31
import getpass
33
32
import os
42
41
    osutils,
43
42
    urlutils,
44
43
    )
 
44
from bzrlib.sixish import (
 
45
    BytesIO,
 
46
    )
45
47
from bzrlib.symbol_versioning import (
46
48
    DEPRECATED_PARAMETER,
47
49
    deprecated_in,
256
258
                        for this operation.
257
259
 
258
260
        We're meant to return a file-like object which bzr will
259
 
        then read from. For now we do this via the magic of StringIO
 
261
        then read from. For now we do this via the magic of BytesIO
260
262
        """
261
263
        try:
262
264
            mutter("FTP get: %s", self._remote_path(relpath))
263
265
            f = self._get_FTP()
264
 
            ret = StringIO()
 
266
            ret = BytesIO()
265
267
            f.retrbinary('RETR '+self._remote_path(relpath), ret.write, 8192)
266
268
            ret.seek(0)
267
269
            return ret
305
307
        if getattr(fp, 'read', None) is None:
306
308
            # hand in a string IO
307
309
            bytes = fp
308
 
            fp = StringIO(bytes)
 
310
            fp = BytesIO(bytes)
309
311
        else:
310
312
            # capture the byte count; .read() may be read only so
311
313
            # decorate it.