Ignore:
Timestamp:
Nov 1, 2015, 10:50:46 PM (4 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Adapt the session, not the session factory

Since the session factory may be a function, not a class, don't adapt
the factory. Instead, adapt the session object after creating it by
using the factory.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ftputil/host.py

    r1601 r1603  
    127127        # `FTPHost` object's child sessions.
    128128        factory = kwargs.pop("session_factory", ftplib.FTP)
    129         # Adapt session factories so that they accept unicode strings
    130         # with non-ASCII characters (as long as the string contains
    131         # only code points <= 255). See the docstring in
     129        with ftputil.error.ftplib_error_to_ftp_os_error:
     130            session = factory(*args, **kwargs)
     131        # Adapt session so that they accept unicode strings with
     132        # non-ASCII characters (as long as the string contains only
     133        # code points <= 255). See the docstring in module
    132134        # `session_adapter` for details.
    133         factory = ftputil.session_adapter.adapted_session_factory(factory)
    134         with ftputil.error.ftplib_error_to_ftp_os_error:
    135             return factory(*args, **kwargs)
     135        return ftputil.session_adapter.adapted_session(session)
    136136
    137137    def _copy(self):
Note: See TracChangeset for help on using the changeset viewer.