Changeset 998:8c59e4da5479


Ignore:
Timestamp:
Nov 14, 2010, 10:53:55 PM (10 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Added unicode checks similar to commit 7ee81a2ca43a to `ftp_path.py`.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ftp_path.py

    r972 r998  
    4343    def abspath(self, path):
    4444        """Return an absolute path."""
     45        # Fail early if we get a unicode path which can't be encoded.
     46        path = str(path)
    4547        if not self.isabs(path):
    4648            path = self.join(self._host.getcwd(), path)
     
    4951    def exists(self, path):
    5052        """Return true if the path exists."""
     53        # Fail early if we get a unicode path which can't be encoded.
     54        path = str(path)
    5155        try:
    5256            lstat_result = self._host.lstat(
     
    6569        server (e. g. timeout).
    6670        """
     71        # Fail early if we get a unicode path which can't be encoded.
     72        path = str(path)
    6773        return self._host.stat(path).st_mtime
    6874
     
    7581        server (e. g. timeout).
    7682        """
     83        # Fail early if we get a unicode path which can't be encoded.
     84        path = str(path)
    7785        return self._host.stat(path).st_size
    7886
     
    94102        A non-existing path does _not_ cause a `PermanentError`.
    95103        """
     104        # Fail early if we get a unicode path which can't be encoded.
     105        path = str(path)
    96106        # Workaround if we can't go up from the current directory
    97107        if path == self._host.getcwd():
     
    114124        A non-existing path does _not_ cause a `PermanentError`.
    115125        """
     126        # Fail early if we get a unicode path which can't be encoded.
     127        path = str(path)
    116128        # Workaround if we can't go up from the current directory
    117129        if path == self._host.getcwd():
     
    133145        A non-existing path does _not_ cause a `PermanentError`.
    134146        """
     147        # Fail early if we get a unicode path which can't be encoded.
     148        path = str(path)
    135149        try:
    136150            lstat_result = self._host.lstat(
     
    161175        to accumulate statistics.  Passing None for arg is common.
    162176        """
     177        # Fail early if we get a unicode path which can't be encoded.
     178        top = str(top)
    163179        # This code (and the above documentation) is taken from
    164180        #  posixpath.py, with slight modifications.
  • test/test_real_ftp.py

    r997 r998  
    738738        self.assert_unicode_error(self.host.chmod, u"ä", 0644)
    739739
     740    def test_path(self):
     741        for method_name in \
     742          "abspath exists getmtime getsize isfile isdir islink".split():
     743            method = getattr(self.host.path, method_name)
     744            self.assert_unicode_error(method, u"ä")
     745
     746    def test_path_walk(self):
     747        def noop():
     748            pass
     749        self.assert_unicode_error(self.host.path.walk, u"ä", noop, None)
     750
    740751
    741752class TestOther(RealFTPTest):
Note: See TracChangeset for help on using the changeset viewer.