Changeset 1901:616e46ca84e0


Ignore:
Timestamp:
Jan 2, 2020, 9:54:52 PM (3 weeks ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Simplify conversion of original exception

In Python 3, exception messages are always unicode strings (`str`),
so special handling for byte string messages is no longer necessary.

When I entered ticket #132, I was under the impression that
`original_exception` was used for exeption chaining and that it could
be removed now. However, `original_exception` is only used to apply
`str(original_exception)` and this use makes sense.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ftputil/error.py

    r1890 r1901  
    4141        super().__init__(*args)
    4242        if "original_exception" in kwargs:
    43             # Byte string under Python 2.
    44             exception_string = str(kwargs.pop("original_exception"))
    45             self.strerror = ftputil.tool.as_str(exception_string)
     43            self.strerror = str(kwargs.pop("original_exception"))
    4644        elif args:
    4745            # If there was no `original_exception` argument, assume
  • test/test_error.py

    r1897 r1901  
    6262        # See ticket #76.
    6363        with pytest.raises(ftputil.error.FTPOSError) as exc_info:
    64             # Format "host:port" doesn't work.
     64            # Format "host:port" doesn't work. The use here is intentional.
    6565            host = ftputil.FTPHost("localhost:21", "", "")
    6666        exc = exc_info.value
Note: See TracChangeset for help on using the changeset viewer.