summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbtimby <btimby@67cdc799-7952-0410-af00-57a81ceafa0f>2013-04-24 13:36:27 +0000
committerbtimby <btimby@67cdc799-7952-0410-af00-57a81ceafa0f>2013-04-24 13:36:27 +0000
commitf2655b37558f4135c8964bf2118c2b6dc4eb88e6 (patch)
tree26776f2dd05468ecf7c9daf23e80681b99a0b48f
parent838bfcd555fd6e4cd7eceaa7ccdbbdc78986cc06 (diff)
downloadpyfilesystem-f2655b37558f4135c8964bf2118c2b6dc4eb88e6.tar.gz
Pyftpdlib 1.x uses unicode, the provided path will already be unicode and thus does not require decoding.
Detect if the provided path is unicode or not before attempting decoding. Use six.unicode to preserve compatibility with py3. git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@855 67cdc799-7952-0410-af00-57a81ceafa0f
-rw-r--r--fs/expose/ftp.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/expose/ftp.py b/fs/expose/ftp.py
index dd77219..de8f418 100644
--- a/fs/expose/ftp.py
+++ b/fs/expose/ftp.py
@@ -28,6 +28,7 @@ from fs.osfs import OSFS
from fs.errors import convert_fs_errors
from fs import iotools
+from six import unicode
# Get these once so we can reuse them:
UID = os.getuid()
@@ -105,7 +106,12 @@ class FTPFS(ftpserver.AbstractedFS):
def chdir(self, path):
# We dont' use the decorator here, we actually decode a version of the
# path for use with pyfs, but keep the original for use with pyftpdlib.
- unipath = unicode(path, self.encoding)
+ if not isinstance(path, unicode):
+ # pyftpdlib 0.7.x
+ unipath = unicode(path, self.encoding)
+ else:
+ # pyftpdlib 1.x
+ unipath = path
# TODO: can the following conditional checks be farmed out to the fs?
# If we don't raise an error here for files, then the FTP server will
# happily allow the client to CWD into a file. We really only want to