mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	Issue #19856: shutil.move() failed to move a directory to other directory
on Windows if source name ends with os.altsep.
This commit is contained in:
		
						commit
						6a45021084
					
				
					 3 changed files with 14 additions and 1 deletions
				
			
		| 
						 | 
					@ -483,7 +483,8 @@ def onerror(*args):
 | 
				
			||||||
def _basename(path):
 | 
					def _basename(path):
 | 
				
			||||||
    # A basename() variant which first strips the trailing slash, if present.
 | 
					    # A basename() variant which first strips the trailing slash, if present.
 | 
				
			||||||
    # Thus we always get the last component of the path, even for directories.
 | 
					    # 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):
 | 
					def move(src, dst):
 | 
				
			||||||
    """Recursively move a file or directory to another location. This is
 | 
					    """Recursively move a file or directory to another location. This is
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1492,6 +1492,15 @@ def test_move_dir_to_dir_other_fs(self):
 | 
				
			||||||
        # Move a dir inside an existing dir on another filesystem.
 | 
					        # Move a dir inside an existing dir on another filesystem.
 | 
				
			||||||
        self.test_move_dir_to_dir()
 | 
					        self.test_move_dir_to_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):
 | 
					    def test_existing_file_inside_dest_dir(self):
 | 
				
			||||||
        # A file with the same name inside the destination dir already exists.
 | 
					        # A file with the same name inside the destination dir already exists.
 | 
				
			||||||
        with open(self.dst_file, "wb"):
 | 
					        with open(self.dst_file, "wb"):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,6 +37,9 @@ Core and Builtins
 | 
				
			||||||
Library
 | 
					Library
 | 
				
			||||||
-------
 | 
					-------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Issue #19856: shutil.move() failed to move a directory to other directory
 | 
				
			||||||
 | 
					  on Windows if source name ends with os.altsep.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Issue #20530: The signatures for slot builtins have been updated
 | 
					- Issue #20530: The signatures for slot builtins have been updated
 | 
				
			||||||
  to reflect the fact that they only accept positional-only arguments.
 | 
					  to reflect the fact that they only accept positional-only arguments.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue