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
014791f8
Kaydet (Commit)
014791f8
authored
Ock 21, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #16993: shutil.which() now preserves the case of the path and extension
on Windows.
üst
85da624e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
9 deletions
+15
-9
shutil.rst
Doc/library/shutil.rst
+1
-1
shutil.py
Lib/shutil.py
+7
-5
test_shutil.py
Lib/test/test_shutil.py
+4
-3
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/shutil.rst
Dosyayı görüntüle @
014791f8
...
...
@@ -335,7 +335,7 @@ Directory and files operations
directories. For example, on Windows::
>>> shutil.which("python")
'
c:\\p
ython33\\python.exe'
'
C:\\P
ython33\\python.exe'
.. versionadded:: 3.3
...
...
Lib/shutil.py
Dosyayı görüntüle @
014791f8
...
...
@@ -1093,10 +1093,12 @@ def which(cmd, mode=os.F_OK | os.X_OK, path=None):
pathext
=
os
.
environ
.
get
(
"PATHEXT"
,
""
)
.
split
(
os
.
pathsep
)
# See if the given file matches any of the expected path extensions.
# This will allow us to short circuit when given "python.exe".
matches
=
[
cmd
for
ext
in
pathext
if
cmd
.
lower
()
.
endswith
(
ext
.
lower
())]
# If it does match, only test that one, otherwise we have to try
# others.
files
=
[
cmd
]
if
matches
else
[
cmd
+
ext
.
lower
()
for
ext
in
pathext
]
if
any
(
cmd
.
lower
()
.
endswith
(
ext
.
lower
())
for
ext
in
pathext
):
files
=
[
cmd
]
else
:
files
=
[
cmd
+
ext
for
ext
in
pathext
]
else
:
# On other platforms you don't have things like PATHEXT to tell you
# what file suffixes are executable, so just pass on cmd as-is.
...
...
@@ -1104,9 +1106,9 @@ def which(cmd, mode=os.F_OK | os.X_OK, path=None):
seen
=
set
()
for
dir
in
path
:
dir
=
os
.
path
.
normcase
(
dir
)
if
not
dir
in
seen
:
seen
.
add
(
dir
)
norm
dir
=
os
.
path
.
normcase
(
dir
)
if
not
norm
dir
in
seen
:
seen
.
add
(
norm
dir
)
for
thefile
in
files
:
name
=
os
.
path
.
join
(
dir
,
thefile
)
if
_access_check
(
name
,
mode
):
...
...
Lib/test/test_shutil.py
Dosyayı görüntüle @
014791f8
...
...
@@ -1269,12 +1269,13 @@ class TestShutil(unittest.TestCase):
class
TestWhich
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
temp_dir
=
tempfile
.
mkdtemp
()
self
.
temp_dir
=
tempfile
.
mkdtemp
(
prefix
=
"Tmp"
)
self
.
addCleanup
(
shutil
.
rmtree
,
self
.
temp_dir
,
True
)
# Give the temp_file an ".exe" suffix for all.
# It's needed on Windows and not harmful on other platforms.
self
.
temp_file
=
tempfile
.
NamedTemporaryFile
(
dir
=
self
.
temp_dir
,
suffix
=
".exe"
)
prefix
=
"Tmp"
,
suffix
=
".Exe"
)
os
.
chmod
(
self
.
temp_file
.
name
,
stat
.
S_IXUSR
)
self
.
addCleanup
(
self
.
temp_file
.
close
)
self
.
dir
,
self
.
file
=
os
.
path
.
split
(
self
.
temp_file
.
name
)
...
...
@@ -1317,7 +1318,7 @@ class TestWhich(unittest.TestCase):
# Ask for the file without the ".exe" extension, then ensure that
# it gets found properly with the extension.
rv
=
shutil
.
which
(
self
.
temp_file
.
name
[:
-
4
],
path
=
self
.
dir
)
self
.
assertEqual
(
self
.
temp_file
.
name
,
rv
)
self
.
assertEqual
(
rv
,
self
.
temp_file
.
name
[:
-
4
]
+
".exe"
)
class
TestMove
(
unittest
.
TestCase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
014791f8
...
...
@@ -150,6 +150,9 @@ Core and Builtins
Library
-------
-
Issue
#
16993
:
shutil
.
which
()
now
preserves
the
case
of
the
path
and
extension
on
Windows
.
-
Issue
#
16992
:
On
Windows
in
signal
.
set_wakeup_fd
,
validate
the
file
descriptor
argument
.
...
...
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