We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 68af202 commit b5b15e0Copy full SHA for b5b15e0
1 file changed
vm/src/stdlib/os.rs
@@ -437,7 +437,17 @@ mod _os {
437
#[pyfunction]
438
fn remove(path: PyPathLike, dir_fd: DirFd, vm: &VirtualMachine) -> PyResult<()> {
439
let path = make_path(vm, &path, &dir_fd)?;
440
- fs::remove_file(path).map_err(|err| err.into_pyexception(vm))
+ let is_junction = cfg!(windows)
441
+ && fs::symlink_metadata(path).map_or(false, |meta| {
442
+ let ty = meta.file_type();
443
+ ty.is_dir() && ty.is_symlink()
444
+ });
445
+ let res = if is_junction {
446
+ fs::remove_dir(path)
447
+ } else {
448
+ fs::remove_file(path)
449
+ };
450
+ res.map_err(|err| err.into_pyexception(vm))
451
}
452
453
0 commit comments