Ignore:
Timestamp:
Aug 3, 2013, 11:53:20 PM (6 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Use more explicit logic. Don't suggest the file object is wrapped when
it actually isn't (under Python 3).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ftputil/file.py

    r1324 r1325  
    4444        that `BufferedReader` or `BufferedWriter` require.
    4545        """
    46         # The `socket.makefile` return value under Python 3 already
    47         # has all the required attributes.
    48         if ftputil.compat.python_version == 3:
    49             return fobj
    5046        # I tried to assign the missing methods as bound methods
    5147        # directly to `fobj`, but this seemingly isn't possible with
     
    117113        fobj = self._conn.makefile(makefile_mode)
    118114        if is_read_mode:
    119             # See implementation of `_wrapped_file`.
    120             fobj = self._wrapped_file(fobj, is_readable=True)
     115            if ftputil.compat.python_version == 2:
     116                # See implementation of `_wrapped_file`.
     117                fobj = self._wrapped_file(fobj, is_readable=True)
    121118            fobj = io.BufferedReader(fobj)
    122119        else:
    123             # See implementation of `_wrapped_file`.
    124             fobj = self._wrapped_file(fobj, is_writable=True)
     120            if ftputil.compat.python_version == 2:
     121                # See implementation of `_wrapped_file`.
     122                fobj = self._wrapped_file(fobj, is_writable=True)
    125123            fobj = io.BufferedWriter(fobj)
    126124        if not is_bin_mode:
    127125            fobj = io.TextIOWrapper(fobj, encoding=encoding,
    128                                         errors=errors, newline=newline)
     126                                    errors=errors, newline=newline)
    129127        self._fobj = fobj
    130128        # This comes last so that `close` won't try to close `_FTPFile`
Note: See TracChangeset for help on using the changeset viewer.