diff Lib/shutil.py --- a/Lib/shutil.py Mon Feb 10 21:43:48 2014 +0100 +++ b/Lib/shutil.py Mon Feb 10 22:42:05 2014 +0100 @@ -259,7 +259,8 @@ def _basename(path): # A basename() variant which first strips the trailing slash, if present. # Thus we always get the last component of the path, even for directories. - return os.path.basename(path.rstrip(os.path.sep)) + sep = os.path.sep + (os.path.altsep or '') + return os.path.basename(path.rstrip(sep)) def move(src, dst): """Recursively move a file or directory to another location. This is diff Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py Mon Feb 10 21:43:48 2014 +0100 +++ b/Lib/test/test_shutil.py Mon Feb 10 22:42:05 2014 +0100 @@ -700,6 +700,15 @@ self._check_move_dir(self.src_dir, self.dir_other_fs, os.path.join(self.dir_other_fs, os.path.basename(self.src_dir))) + def test_move_dir_sep_to_dir(self): + self._check_move_dir(self.src_dir + os.path.sep, self.dst_dir, + os.path.join(self.dst_dir, os.path.basename(self.src_dir))) + + @unittest.skipUnless(os.path.altsep, 'requires os.path.altsep') + def test_move_dir_altsep_to_dir(self): + self._check_move_dir(self.src_dir + os.path.altsep, self.dst_dir, + os.path.join(self.dst_dir, os.path.basename(self.src_dir))) + def test_existing_file_inside_dest_dir(self): # A file with the same name inside the destination dir already exists. with open(self.dst_file, "wb"):