Skip to content

Commit

Permalink
Fixes _chdir() on PY3
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Nov 14, 2014
1 parent 16b7209 commit 2964de5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scp.py
Expand Up @@ -237,12 +237,12 @@ def _chdir(self, from_dir, to_dir):

# add path.sep to each when checking the prefix, so we can use
# path.dirname after
common = os.path.commonprefix([from_dir + os.path.sep,
to_dir + os.path.sep])
common = os.path.commonprefix([from_dir + b'/',
to_dir + b'/'])
# now take the dirname, since commonprefix is character based,
# and we either have a seperator, or a partial name
common = os.path.dirname(common)
cur_dir = from_dir.rstrip(os.path.sep)
cur_dir = from_dir.rstrip(b'/')
while cur_dir != common:
cur_dir = os.path.split(cur_dir)[0]
self._send_popd()
Expand All @@ -259,7 +259,7 @@ def _send_recursive(self, files):
for root, dirs, fls in os.walk(base):
self._chdir(last_dir, asbytes(root))
self._send_files([os.path.join(root, f) for f in fls])
last_dir = root
last_dir = asbytes(root)
# back out of the directory
for i in range(len(os.path.split(last_dir))):
self._send_popd()
Expand Down

0 comments on commit 2964de5

Please sign in to comment.