Changeset 1716:208cec5f1797
- Timestamp:
- Dec 25, 2018, 11:05:14 PM (2 years ago)
- Branch:
- default
- histedit_source:
- 11cfc2f98c21adea8ce3b9407ef189e8c561b2bf,0413bb6d5c9a453741738fe21242d768e389f8b9
- Location:
- ftputil
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ftputil/file.py
r1713 r1716 11 11 import ftputil.compat 12 12 import ftputil.error 13 import ftputil.socket_file_adapter14 13 15 14 … … 52 51 # pylint: disable=unused-argument 53 52 # 54 # Python 3's `socket.makefile` supports the same interface as55 # the new `open` builtin, but Python 2 supports only a mode,56 # but doesn't return an object with the proper interface to57 # wrap it in `io.TextIOWrapper`.58 #59 # Therefore, to make the code work on Python 2 _and_ 3, use60 # `socket.makefile` to always create a binary file and under61 # Python 2 wrap it in an adapter class.62 #63 53 # Check mode. 64 54 if "a" in mode: … … 95 85 # `BufferedReader` or `BufferedWriter` object. 96 86 fobj = self._conn.makefile(makefile_mode) 97 if ftputil.compat.python_version == 2:98 BufferedIOAdapter = ftputil.socket_file_adapter.BufferedIOAdapter99 if is_read_mode:100 fobj = BufferedIOAdapter(fobj, is_readable=True)101 else:102 fobj = BufferedIOAdapter(fobj, is_writable=True)103 87 if not is_binary_mode: 104 88 fobj = io.TextIOWrapper(fobj, encoding=encoding,
Note: See TracChangeset
for help on using the changeset viewer.