Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
84c0ca06
Commit
84c0ca06
authored
Apr 22, 2012
by
Charles-François Natali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use os.path.samestat() instead of reinventing the wheel.
parent
243994dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
9 deletions
+2
-9
Lib/os.py
Lib/os.py
+2
-9
No files found.
Lib/os.py
View file @
84c0ca06
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment