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
b5689de0
Kaydet (Commit)
b5689de0
authored
Ock 12, 2010
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#5827: make sure that normpath preserves unicode
üst
58a96efd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
8 deletions
+25
-8
ntpath.py
Lib/ntpath.py
+6
-4
posixpath.py
Lib/posixpath.py
+6
-4
test_ntpath.py
Lib/test/test_ntpath.py
+5
-0
test_posixpath.py
Lib/test/test_posixpath.py
+5
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/ntpath.py
Dosyayı görüntüle @
b5689de0
...
...
@@ -397,6 +397,8 @@ def expandvars(path):
def
normpath
(
path
):
"""Normalize path, eliminating double slashes, etc."""
# Preserve unicode (if path is unicode)
backslash
,
dot
=
(
u'
\\
'
,
u'.'
)
if
isinstance
(
path
,
unicode
)
else
(
'
\\
'
,
'.'
)
path
=
path
.
replace
(
"/"
,
"
\\
"
)
prefix
,
path
=
splitdrive
(
path
)
# We need to be careful here. If the prefix is empty, and the path starts
...
...
@@ -411,12 +413,12 @@ def normpath(path):
if
prefix
==
''
:
# No drive letter - preserve initial backslashes
while
path
[:
1
]
==
"
\\
"
:
prefix
=
prefix
+
"
\\
"
prefix
=
prefix
+
backslash
path
=
path
[
1
:]
else
:
# We have a drive letter - collapse initial backslashes
if
path
.
startswith
(
"
\\
"
):
prefix
=
prefix
+
"
\\
"
prefix
=
prefix
+
backslash
path
=
path
.
lstrip
(
"
\\
"
)
comps
=
path
.
split
(
"
\\
"
)
i
=
0
...
...
@@ -435,8 +437,8 @@ def normpath(path):
i
+=
1
# If the path is now empty, substitute '.'
if
not
prefix
and
not
comps
:
comps
.
append
(
'.'
)
return
prefix
+
"
\\
"
.
join
(
comps
)
comps
.
append
(
dot
)
return
prefix
+
backslash
.
join
(
comps
)
# Return an absolute path.
...
...
Lib/posixpath.py
Dosyayı görüntüle @
b5689de0
...
...
@@ -307,8 +307,10 @@ def expandvars(path):
def
normpath
(
path
):
"""Normalize path, eliminating double slashes, etc."""
# Preserve unicode (if path is unicode)
slash
,
dot
=
(
u'/'
,
u'.'
)
if
isinstance
(
path
,
unicode
)
else
(
'/'
,
'.'
)
if
path
==
''
:
return
'.'
return
dot
initial_slashes
=
path
.
startswith
(
'/'
)
# POSIX allows one or two initial slashes, but treats three or more
# as single slash.
...
...
@@ -326,10 +328,10 @@ def normpath(path):
elif
new_comps
:
new_comps
.
pop
()
comps
=
new_comps
path
=
'/'
.
join
(
comps
)
path
=
slash
.
join
(
comps
)
if
initial_slashes
:
path
=
'/'
*
initial_slashes
+
path
return
path
or
'.'
path
=
slash
*
initial_slashes
+
path
return
path
or
dot
def
abspath
(
path
):
...
...
Lib/test/test_ntpath.py
Dosyayı görüntüle @
b5689de0
...
...
@@ -123,6 +123,11 @@ class TestNtpath(unittest.TestCase):
tester
(
"ntpath.normpath('C:////a/b')"
,
r'C:\a\b'
)
tester
(
"ntpath.normpath('//machine/share//a/b')"
,
r'\\machine\share\a\b'
)
# Issue 5827: Make sure normpath preserves unicode
for
path
in
(
u''
,
u'.'
,
u'/'
,
u'
\\
'
,
u'///foo/.//bar//'
):
self
.
assertTrue
(
isinstance
(
ntpath
.
normpath
(
path
),
unicode
),
'normpath() returned str instead of unicode'
)
def
test_expandvars
(
self
):
with
test_support
.
EnvironmentVarGuard
()
as
env
:
env
.
clear
()
...
...
Lib/test/test_posixpath.py
Dosyayı görüntüle @
b5689de0
...
...
@@ -381,6 +381,11 @@ class PosixPathTest(unittest.TestCase):
self
.
assertEqual
(
posixpath
.
normpath
(
"///foo/.//bar//.//..//.//baz"
),
"/foo/baz"
)
self
.
assertEqual
(
posixpath
.
normpath
(
"///..//./foo/.//bar"
),
"/foo/bar"
)
# Issue 5827: Make sure normpath preserves unicode
for
path
in
(
u''
,
u'.'
,
u'/'
,
u'
\\
'
,
u'///foo/.//bar//'
):
self
.
assertTrue
(
isinstance
(
posixpath
.
normpath
(
path
),
unicode
),
'normpath() returned str instead of unicode'
)
self
.
assertRaises
(
TypeError
,
posixpath
.
normpath
)
def
test_abspath
(
self
):
...
...
Misc/NEWS
Dosyayı görüntüle @
b5689de0
...
...
@@ -23,6 +23,9 @@ Core and Builtins
Library
-------
- Issue #5827: Make sure that normpath preserves unicode. Initial patch
by Matt Giuca.
- Issue #5372: Drop the reuse of .o files in Distutils' ccompiler (since
Extension extra options may change the output without changing the .c
file). Initial patch by Collin Winter.
...
...
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