diff options
author | Larry Hastings <larry@hastings.org> | 2012-06-23 23:55:07 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2012-06-23 23:55:07 (GMT) |
commit | b698d8e7e91061fd247743b31b7228dc64eceba8 (patch) | |
tree | 5f872cf5f5303bfa282a3dce641f1df6b579378c /Lib | |
parent | b7eb563a2a69ba7182b8dc0634b53dc37b7d93a1 (diff) | |
download | cpython-b698d8e7e91061fd247743b31b7228dc64eceba8.zip cpython-b698d8e7e91061fd247743b31b7228dc64eceba8.tar.gz cpython-b698d8e7e91061fd247743b31b7228dc64eceba8.tar.bz2 |
Issue #15154: Add "dir_fd" parameter to os.rmdir, remove "rmdir"
parameter from os.remove / os.unlink.
Patch written by Georg Brandl. (I'm really looking forward to George
getting commit privileges so I don't have to keep doing checkins on his
behalf.)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/os.py | 5 | ||||
-rw-r--r-- | Lib/test/test_os.py | 5 |
2 files changed, 5 insertions, 5 deletions
@@ -157,6 +157,7 @@ if _exists("_have_functions"): _add("HAVE_RENAMEAT", "rename") _add("HAVE_SYMLINKAT", "symlink") _add("HAVE_UNLINKAT", "unlink") + _add("HAVE_UNLINKAT", "rmdir") _add("HAVE_UTIMENSAT", "utime") supports_dir_fd = _set @@ -214,10 +215,6 @@ if _exists("_have_functions"): _add("MS_WINDOWS", "stat") supports_follow_symlinks = _set - _set = set() - _add("HAVE_UNLINKAT", "unlink") - supports_remove_directory = _set - del _set del _have_functions del _globals diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index cc1120f..654dd23 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -785,7 +785,10 @@ class FwalkTests(WalkTests): os.unlink(name, dir_fd=rootfd) for name in dirs: st = os.stat(name, dir_fd=rootfd, follow_symlinks=False) - os.unlink(name, dir_fd=rootfd, rmdir=stat.S_ISDIR(st.st_mode)) + if stat.S_ISDIR(st.st_mode): + os.rmdir(name, dir_fd=rootfd) + else: + os.unlink(name, dir_fd=rootfd) os.rmdir(support.TESTFN) |