Changeset 1278:831382d92a2d


Ignore:
Timestamp:
Jul 28, 2013, 1:26:55 PM (7 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Accept bytes or unicode strings for the path in `FTPHost.path.walk`.
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ftputil/host.py

    r1273 r1278  
    812812        any of the available parsers raise a `ParserError`.
    813813        """
    814         # Fail early if we get a unicode path which can't be encoded.
    815         path = str(path)
    816814        return self._stat._listdir(path)
    817815
  • ftputil/path.py

    r1276 r1278  
    166166        to accumulate statistics.  Passing None for arg is common.
    167167        """
    168         # Fail early if we get a unicode path which can't be encoded.
    169         top = str(top)
     168        top = ftputil.tool.as_unicode(top)
    170169        # This code (and the above documentation) is taken from
    171170        # posixpath.py, with slight modifications.
  • test/test_path.py

    r1277 r1278  
    168168        self.assertEqual(host.path.getsize(as_bytes("ä")), 512)
    169169
    170     def test_types_for_path_walk(self):
     170    def test_types_for_walk(self):
    171171        """Test whether `FTPHost.path.walk` accepts bytes and unicode paths."""
     172        host = self.host
     173        as_bytes = ftputil.tool.as_bytes
     174        def noop(arg, top, names):
     175            del names[:]
     176        host.path.walk("ä", noop, None)
     177        host.path.walk(as_bytes("ä"), noop, None)
    172178
    173179
  • test/test_real_ftp.py

    r1273 r1278  
    810810#             self.assert_unicode_error(method, "ä")
    811811
    812     def test_path_walk(self):
    813         def noop():
    814             pass
    815         self.assert_unicode_error(self.host.path.walk, "ä", noop, None)
     812#     def test_path_walk(self):
     813#         def noop():
     814#             pass
     815#         self.assert_unicode_error(self.host.path.walk, "ä", noop, None)
    816816
    817817
Note: See TracChangeset for help on using the changeset viewer.