From: Charles-François Natali Date: Sun, 22 Apr 2012 13:55:43 +0000 (+0200) Subject: Use os.path.samestat() instead of reinventing the wheel. X-Git-Tag: v3.3.0a3~115^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84c0ca06d2fe3c773dce722baa5babbdbf73aaa0;p=python Use os.path.samestat() instead of reinventing the wheel. --- diff --git a/Lib/os.py b/Lib/os.py index bd1802345b..2c7d954864 100644 --- a/Lib/os.py +++ b/Lib/os.py @@ -126,13 +126,6 @@ def _get_masked_mode(mode): umask(mask) return mode & ~mask -def _are_same_file(stat1, stat2): - """Helper function that checks whether two stat results refer to the same - file. - """ - return (stat1.st_ino == stat2.st_ino and stat1.st_dev == stat2.st_dev) -# - # Super directory utilities. # (Inspired by Eric Raymond; the doc strings are mostly his) @@ -345,7 +338,7 @@ if _exists("openat"): topfd = open(top, O_RDONLY) try: if (followlinks or (st.S_ISDIR(orig_st.st_mode) and - _are_same_file(orig_st, fstat(topfd)))): + path.samestat(orig_st, fstat(topfd)))): for x in _fwalk(topfd, top, topdown, onerror, followlinks): yield x finally: @@ -382,7 +375,7 @@ if _exists("openat"): onerror(err) return try: - if followlinks or _are_same_file(orig_st, fstat(dirfd)): + if followlinks or path.samestat(orig_st, fstat(dirfd)): dirpath = path.join(toppath, name) for x in _fwalk(dirfd, dirpath, topdown, onerror, followlinks): yield x