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
92521fea
Commit
92521fea
authored
Sep 11, 2019
by
Steve Dower
Committed by
Zachary Ware
Sep 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-38081: Fixes ntpath.realpath('NUL') (GH-15899)
parent
455122a0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
+12
-6
Lib/ntpath.py
Lib/ntpath.py
+7
-6
Lib/test/test_ntpath.py
Lib/test/test_ntpath.py
+4
-0
Misc/NEWS.d/next/Windows/2019-09-11-10-22-01.bpo-38081.8JhzjD.rst
...S.d/next/Windows/2019-09-11-10-22-01.bpo-38081.8JhzjD.rst
+1
-0
No files found.
Lib/ntpath.py
View file @
92521fea
...
@@ -535,9 +535,10 @@ else:
...
@@ -535,9 +535,10 @@ else:
try
:
try
:
path
=
_nt_readlink
(
path
)
path
=
_nt_readlink
(
path
)
except
OSError
as
ex
:
except
OSError
as
ex
:
# Stop on file (2) or directory (3) not found, or
# Stop on incorrect function (1), file (2) or
# paths that are not reparse points (4390)
# directory (3) not found, or paths that are
if
ex
.
winerror
in
(
2
,
3
,
4390
):
# not reparse points (4390)
if
ex
.
winerror
in
(
1
,
2
,
3
,
4390
):
break
break
raise
raise
except
ValueError
:
except
ValueError
:
...
@@ -553,9 +554,9 @@ else:
...
@@ -553,9 +554,9 @@ else:
except
OSError
:
except
OSError
:
pass
pass
# Allow file (2) or directory (3) not found, in
valid syntax (123
),
# Allow file (2) or directory (3) not found, in
correct parameter (87
),
# and symlinks that cannot be followed (1921)
#
invalid syntax (123),
and symlinks that cannot be followed (1921)
allowed_winerror
=
2
,
3
,
123
,
1921
allowed_winerror
=
2
,
3
,
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.
...
...
Lib/test/test_ntpath.py
View file @
92521fea
...
@@ -400,6 +400,10 @@ class TestNtpath(NtpathTestCase):
...
@@ -400,6 +400,10 @@ class TestNtpath(NtpathTestCase):
self.assertPathEqual(ntpath.realpath("
\
\
\
\
?
\
\
" + ABSTFN + "3.link"),
self.assertPathEqual(ntpath.realpath("
\
\
\
\
?
\
\
" + ABSTFN + "3.link"),
"
\
\
\
\
?
\
\
" + ABSTFN + "3.")
"
\
\
\
\
?
\
\
" + ABSTFN + "3.")
@unittest.skipUnless(HAVE_GETFINALPATHNAME, '
need
_getfinalpathname
')
def test_realpath_nul(self):
tester("ntpath.realpath('
NUL
')", r'
\\
.
\
NUL
')
def test_expandvars(self):
def test_expandvars(self):
with support.EnvironmentVarGuard() as env:
with support.EnvironmentVarGuard() as env:
env.clear()
env.clear()
...
...
Misc/NEWS.d/next/Windows/2019-09-11-10-22-01.bpo-38081.8JhzjD.rst
0 → 100644
View file @
92521fea
Prevent error calling :func:`os.path.realpath` on ``'NUL'``.
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