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
a993902a
Kaydet (Commit)
a993902a
authored
Ara 06, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #19908: pathlib now joins relative Windows paths correctly when a drive
is present. Original patch by Antoine Pitrou.
üst
1b8b868b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
5 deletions
+53
-5
pathlib.py
Lib/pathlib.py
+9
-5
test_pathlib.py
Lib/test/test_pathlib.py
+42
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/pathlib.py
Dosyayı görüntüle @
a993902a
...
@@ -89,12 +89,16 @@ class _Flavour(object):
...
@@ -89,12 +89,16 @@ class _Flavour(object):
(drive, root, parts) tuples. Return a new (drive, root, parts) tuple.
(drive, root, parts) tuples. Return a new (drive, root, parts) tuple.
"""
"""
if
root2
:
if
root2
:
parts
=
parts2
if
not
drv2
and
drv
:
root
=
root2
return
drv
,
root2
,
[
drv
+
root2
]
+
parts2
[
1
:]
elif
drv2
:
if
drv2
==
drv
or
self
.
casefold
(
drv2
)
==
self
.
casefold
(
drv
):
# Same drive => second path is relative to the first
return
drv
,
root
,
parts
+
parts2
[
1
:]
else
:
else
:
parts
=
parts
+
parts2
# Second path is non-anchored (common case)
# XXX raise error if drv and drv2 are different?
return
drv
,
root
,
parts
+
parts2
return
drv2
or
drv
,
root
,
parts
return
drv2
,
root2
,
parts2
class
_WindowsFlavour
(
_Flavour
):
class
_WindowsFlavour
(
_Flavour
):
...
...
Lib/test/test_pathlib.py
Dosyayı görüntüle @
a993902a
...
@@ -975,6 +975,48 @@ class PureWindowsPathTest(_BasePurePathTest, unittest.TestCase):
...
@@ -975,6 +975,48 @@ class PureWindowsPathTest(_BasePurePathTest, unittest.TestCase):
self
.
assertTrue
(
P
(
'//a/b/c'
)
.
is_absolute
())
self
.
assertTrue
(
P
(
'//a/b/c'
)
.
is_absolute
())
self
.
assertTrue
(
P
(
'//a/b/c/d'
)
.
is_absolute
())
self
.
assertTrue
(
P
(
'//a/b/c/d'
)
.
is_absolute
())
def
test_join
(
self
):
P
=
self
.
cls
p
=
P
(
'C:/a/b'
)
pp
=
p
.
joinpath
(
'x/y'
)
self
.
assertEqual
(
pp
,
P
(
'C:/a/b/x/y'
))
pp
=
p
.
joinpath
(
'/x/y'
)
self
.
assertEqual
(
pp
,
P
(
'C:/x/y'
))
# Joining with a different drive => the first path is ignored, even
# if the second path is relative.
pp
=
p
.
joinpath
(
'D:x/y'
)
self
.
assertEqual
(
pp
,
P
(
'D:x/y'
))
pp
=
p
.
joinpath
(
'D:/x/y'
)
self
.
assertEqual
(
pp
,
P
(
'D:/x/y'
))
pp
=
p
.
joinpath
(
'//host/share/x/y'
)
self
.
assertEqual
(
pp
,
P
(
'//host/share/x/y'
))
# Joining with the same drive => the first path is appended to if
# the second path is relative.
pp
=
p
.
joinpath
(
'c:x/y'
)
self
.
assertEqual
(
pp
,
P
(
'C:/a/b/x/y'
))
pp
=
p
.
joinpath
(
'c:/x/y'
)
self
.
assertEqual
(
pp
,
P
(
'C:/x/y'
))
def
test_div
(
self
):
# Basically the same as joinpath()
P
=
self
.
cls
p
=
P
(
'C:/a/b'
)
self
.
assertEqual
(
p
/
'x/y'
,
P
(
'C:/a/b/x/y'
))
self
.
assertEqual
(
p
/
'x'
/
'y'
,
P
(
'C:/a/b/x/y'
))
self
.
assertEqual
(
p
/
'/x/y'
,
P
(
'C:/x/y'
))
self
.
assertEqual
(
p
/
'/x'
/
'y'
,
P
(
'C:/x/y'
))
# Joining with a different drive => the first path is ignored, even
# if the second path is relative.
self
.
assertEqual
(
p
/
'D:x/y'
,
P
(
'D:x/y'
))
self
.
assertEqual
(
p
/
'D:'
/
'x/y'
,
P
(
'D:x/y'
))
self
.
assertEqual
(
p
/
'D:/x/y'
,
P
(
'D:/x/y'
))
self
.
assertEqual
(
p
/
'D:'
/
'/x/y'
,
P
(
'D:/x/y'
))
self
.
assertEqual
(
p
/
'//host/share/x/y'
,
P
(
'//host/share/x/y'
))
# Joining with the same drive => the first path is appended to if
# the second path is relative.
self
.
assertEqual
(
p
/
'C:x/y'
,
P
(
'C:/a/b/x/y'
))
self
.
assertEqual
(
p
/
'C:/x/y'
,
P
(
'C:/x/y'
))
def
test_is_reserved
(
self
):
def
test_is_reserved
(
self
):
P
=
self
.
cls
P
=
self
.
cls
self
.
assertIs
(
False
,
P
(
''
)
.
is_reserved
())
self
.
assertIs
(
False
,
P
(
''
)
.
is_reserved
())
...
...
Misc/NEWS
Dosyayı görüntüle @
a993902a
...
@@ -18,6 +18,8 @@ Core and Builtins
...
@@ -18,6 +18,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #19908: pathlib now joins relative Windows paths correctly when a drive
is present. Original patch by Antoine Pitrou.
- Issue #19296: Silence compiler warning in dbm_open
- Issue #19296: Silence compiler warning in dbm_open
...
...
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