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
89b8933b
Commit
89b8933b
authored
Sep 16, 2019
by
Steve Dower
Committed by
GitHub
Sep 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-38081: Add more non-fatal error codes for ntpath.realpath (GH-16156)
parent
3ab73f6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
7 deletions
+34
-7
Lib/ntpath.py
Lib/ntpath.py
+34
-7
No files found.
Lib/ntpath.py
View file @
89b8933b
...
@@ -530,15 +530,28 @@ else:
...
@@ -530,15 +530,28 @@ else:
if
seen
is
None
:
if
seen
is
None
:
seen
=
set
()
seen
=
set
()
# These error codes indicate that we should stop reading links and
# return the path we currently have.
# 1: ERROR_INVALID_FUNCTION
# 2: ERROR_FILE_NOT_FOUND
# 3: ERROR_DIRECTORY_NOT_FOUND
# 5: ERROR_ACCESS_DENIED
# 21: ERROR_NOT_READY (implies drive with no media)
# 32: ERROR_SHARING_VIOLATION (probably an NTFS paging file)
# 50: ERROR_NOT_SUPPORTED (implies no support for reparse points)
# 67: ERROR_BAD_NET_NAME (implies remote server unavailable)
# 87: ERROR_INVALID_PARAMETER
# 4390: ERROR_NOT_A_REPARSE_POINT
# 4392: ERROR_INVALID_REPARSE_DATA
# 4393: ERROR_REPARSE_TAG_INVALID
allowed_winerror
=
1
,
2
,
3
,
5
,
21
,
32
,
50
,
67
,
87
,
4390
,
4392
,
4393
while
normcase
(
path
)
not
in
seen
:
while
normcase
(
path
)
not
in
seen
:
seen
.
add
(
normcase
(
path
))
seen
.
add
(
normcase
(
path
))
try
:
try
:
path
=
_nt_readlink
(
path
)
path
=
_nt_readlink
(
path
)
except
OSError
as
ex
:
except
OSError
as
ex
:
# Stop on incorrect function (1), file (2) or
if
ex
.
winerror
in
allowed_winerror
:
# directory (3) not found, or paths that are
# not reparse points (4390)
if
ex
.
winerror
in
(
1
,
2
,
3
,
4390
):
break
break
raise
raise
except
ValueError
:
except
ValueError
:
...
@@ -554,9 +567,20 @@ else:
...
@@ -554,9 +567,20 @@ else:
except
OSError
:
except
OSError
:
pass
pass
# Allow file (2) or directory (3) not found, incorrect parameter (87),
# These error codes indicate that we should stop resolving the path
# invalid syntax (123), and symlinks that cannot be followed (1921)
# and return the value we currently have.
allowed_winerror
=
2
,
3
,
87
,
123
,
1921
# 1: ERROR_INVALID_FUNCTION
# 2: ERROR_FILE_NOT_FOUND
# 3: ERROR_DIRECTORY_NOT_FOUND
# 5: ERROR_ACCESS_DENIED
# 21: ERROR_NOT_READY (implies drive with no media)
# 32: ERROR_SHARING_VIOLATION (probably an NTFS paging file)
# 50: ERROR_NOT_SUPPORTED
# 67: ERROR_BAD_NET_NAME (implies remote server unavailable)
# 87: ERROR_INVALID_PARAMETER
# 123: ERROR_INVALID_NAME
# 1921: ERROR_CANT_RESOLVE_FILENAME (implies unfollowable symlink)
allowed_winerror
=
1
,
2
,
3
,
5
,
21
,
32
,
50
,
67
,
87
,
123
,
1921
# Non-strict algorithm is to find as much of the target directory
# Non-strict algorithm is to find as much of the target directory
# as we can and join the rest.
# as we can and join the rest.
...
@@ -571,6 +595,9 @@ else:
...
@@ -571,6 +595,9 @@ else:
if
ex
.
winerror
not
in
allowed_winerror
:
if
ex
.
winerror
not
in
allowed_winerror
:
raise
raise
path
,
name
=
split
(
path
)
path
,
name
=
split
(
path
)
# TODO (bpo-38186): Request the real file name from the directory
# entry using FindFirstFileW. For now, we will return the path
# as best we have it
if
path
and
not
name
:
if
path
and
not
name
:
return
abspath
(
path
+
tail
)
return
abspath
(
path
+
tail
)
tail
=
join
(
name
,
tail
)
if
tail
else
name
tail
=
join
(
name
,
tail
)
if
tail
else
name
...
...
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