Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
b0bf51b3
Unverified
Kaydet (Commit)
b0bf51b3
authored
Agu 07, 2018
tarafından
Steve Dower
Kaydeden (comit)
GitHub
Agu 07, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-31047: Fix ntpath.abspath for invalid paths (GH-8544)
üst
3da5c5c7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
22 deletions
+26
-22
ntpath.py
Lib/ntpath.py
+20
-22
test_ntpath.py
Lib/test/test_ntpath.py
+4
-0
2018-07-29-14-12-23.bpo-31047.FSarLs.rst
...S.d/next/Library/2018-07-29-14-12-23.bpo-31047.FSarLs.rst
+2
-0
No files found.
Lib/ntpath.py
Dosyayı görüntüle @
b0bf51b3
...
...
@@ -518,38 +518,36 @@ def normpath(path):
comps
.
append
(
curdir
)
return
prefix
+
sep
.
join
(
comps
)
def
_abspath_fallback
(
path
):
"""Return the absolute version of a path as a fallback function in case
`nt._getfullpathname` is not available or raises OSError. See bpo-31047 for
more.
"""
path
=
os
.
fspath
(
path
)
if
not
isabs
(
path
):
if
isinstance
(
path
,
bytes
):
cwd
=
os
.
getcwdb
()
else
:
cwd
=
os
.
getcwd
()
path
=
join
(
cwd
,
path
)
return
normpath
(
path
)
# Return an absolute path.
try
:
from
nt
import
_getfullpathname
except
ImportError
:
# not running on Windows - mock up something sensible
def
abspath
(
path
):
"""Return the absolute version of a path."""
path
=
os
.
fspath
(
path
)
if
not
isabs
(
path
):
if
isinstance
(
path
,
bytes
):
cwd
=
os
.
getcwdb
()
else
:
cwd
=
os
.
getcwd
()
path
=
join
(
cwd
,
path
)
return
normpath
(
path
)
abspath
=
_abspath_fallback
else
:
# use native Windows method on Windows
def
abspath
(
path
):
"""Return the absolute version of a path."""
if
path
:
# Empty path must return current working directory.
path
=
os
.
fspath
(
path
)
try
:
path
=
_getfullpathname
(
path
)
except
OSError
:
pass
# Bad path - return unchanged.
elif
isinstance
(
path
,
bytes
):
path
=
os
.
getcwdb
()
else
:
path
=
os
.
getcwd
()
return
normpath
(
path
)
try
:
return
_getfullpathname
(
path
)
except
OSError
:
return
_abspath_fallback
(
path
)
# realpath is a no-op on systems without islink support
realpath
=
abspath
...
...
Lib/test/test_ntpath.py
Dosyayı görüntüle @
b0bf51b3
...
...
@@ -303,6 +303,10 @@ class TestNtpath(unittest.TestCase):
try
:
import
nt
tester
(
'ntpath.abspath("C:
\\
")'
,
"C:
\\
"
)
with
support
.
temp_cwd
(
support
.
TESTFN
)
as
cwd_dir
:
# bpo-31047
tester
(
'ntpath.abspath("")'
,
cwd_dir
)
tester
(
'ntpath.abspath(" ")'
,
cwd_dir
+
"
\\
"
)
tester
(
'ntpath.abspath("?")'
,
cwd_dir
+
"
\\
?"
)
except
ImportError
:
self
.
skipTest
(
'nt module not available'
)
...
...
Misc/NEWS.d/next/Library/2018-07-29-14-12-23.bpo-31047.FSarLs.rst
0 → 100644
Dosyayı görüntüle @
b0bf51b3
Fix ``ntpath.abspath`` for invalid paths on windows. Patch by Franz
Woellert.
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