Changeset 1502:23f0bc574981


Ignore:
Timestamp:
Apr 23, 2014, 8:14:45 AM (7 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Raise `TypeError` instead of `PicklingError`.

See also
https://mail.python.org/pipermail/python-list/2014-April/671002.html
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ftputil/file.py

    r1482 r1502  
    1111
    1212import io
    13 import pickle
    1413
    1514import ftputil.compat
     
    304303
    305304    def __getstate__(self):
    306         raise pickle.PicklingError("pickling is deliberately unsupported")
     305        raise TypeError("cannot serialize FTPFile object")
  • ftputil/host.py

    r1482 r1502  
    1313
    1414import ftplib
    15 import pickle
    1615import stat
    1716import sys
     
    900899
    901900    def __getstate__(self):
    902         raise pickle.PicklingError("pickling is deliberately unsupported")
     901        raise TypeError("cannot serialize FTPHost object")
    903902
    904903    #
  • test/test_host.py

    r1482 r1502  
    574574        """Test if pickling (intentionally) isn't supported."""
    575575        with test_base.ftp_host_factory() as host:
    576             self.assertRaises(pickle.PicklingError, pickle.dumps, host)
     576            self.assertRaises(TypeError, pickle.dumps, host)
    577577            with host.open("/home/sschwarzer/index.html") as file_obj:
    578                 self.assertRaises(pickle.PicklingError, pickle.dumps, file_obj)
     578                self.assertRaises(TypeError, pickle.dumps, file_obj)
    579579
    580580
Note: See TracChangeset for help on using the changeset viewer.