[Python-checkins] cpython: Use os.path.samestat() instead of reinventing the wheel.

charles-francois.natali python-checkins at python.org
Sun Apr 22 15:56:12 CEST 2012


http://hg.python.org/cpython/rev/b3a565e9701e
changeset: 76471:b3a565e9701e
user: Charles-François Natali <neologix at free.fr>
date: Sun Apr 22 15:55:43 2012 +0200
summary:
 Use os.path.samestat() instead of reinventing the wheel.
files:
 Lib/os.py | 11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/Lib/os.py b/Lib/os.py
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -126,13 +126,6 @@
 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 @@
 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 @@
 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
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /