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
a12df7b7
Kaydet (Commit)
a12df7b7
authored
May 05, 2017
tarafından
Jelle Zijlstra
Kaydeden (comit)
Brett Cannon
May 05, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-30218: support path-like objects in shutil.unpack_archive() (GH-1367)
Thanks to Jelle Zijlstra for the patch.
üst
a1054c3b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
4 deletions
+26
-4
shutil.rst
Doc/library/shutil.rst
+3
-0
shutil.py
Lib/shutil.py
+3
-0
test_shutil.py
Lib/test/test_shutil.py
+17
-4
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/shutil.rst
Dosyayı görüntüle @
a12df7b7
...
...
@@ -550,6 +550,9 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
registered for that extension. In case none is found,
a :exc:`ValueError` is raised.
.. versionchanged:: 3.7
Accepts a :term:`path-like object` for *filename* and *extract_dir*.
.. function:: register_unpack_format(name, extensions, function[, extra_args[, description]])
...
...
Lib/shutil.py
Dosyayı görüntüle @
a12df7b7
...
...
@@ -958,6 +958,9 @@ def unpack_archive(filename, extract_dir=None, format=None):
if
extract_dir
is
None
:
extract_dir
=
os
.
getcwd
()
extract_dir
=
os
.
fspath
(
extract_dir
)
filename
=
os
.
fspath
(
filename
)
if
format
is
not
None
:
try
:
format_info
=
_UNPACK_FORMATS
[
format
]
...
...
Lib/test/test_shutil.py
Dosyayı görüntüle @
a12df7b7
...
...
@@ -10,6 +10,7 @@ import os
import
os.path
import
errno
import
functools
import
pathlib
import
subprocess
from
shutil
import
(
make_archive
,
register_archive_format
,
unregister_archive_format
,
...
...
@@ -1223,6 +1224,18 @@ class TestShutil(unittest.TestCase):
self
.
assertNotIn
(
'xxx'
,
formats
)
def
check_unpack_archive
(
self
,
format
):
self
.
check_unpack_archive_with_converter
(
format
,
lambda
path
:
path
)
self
.
check_unpack_archive_with_converter
(
format
,
pathlib
.
Path
)
class
MyPath
:
def
__init__
(
self
,
path
):
self
.
path
=
path
def
__fspath__
(
self
):
return
self
.
path
self
.
check_unpack_archive_with_converter
(
format
,
MyPath
)
def
check_unpack_archive_with_converter
(
self
,
format
,
converter
):
root_dir
,
base_dir
=
self
.
_create_files
()
expected
=
rlistdir
(
root_dir
)
expected
.
remove
(
'outer'
)
...
...
@@ -1232,16 +1245,16 @@ class TestShutil(unittest.TestCase):
# let's try to unpack it now
tmpdir2
=
self
.
mkdtemp
()
unpack_archive
(
filename
,
tmpdir2
)
unpack_archive
(
converter
(
filename
),
converter
(
tmpdir2
)
)
self
.
assertEqual
(
rlistdir
(
tmpdir2
),
expected
)
# and again, this time with the format specified
tmpdir3
=
self
.
mkdtemp
()
unpack_archive
(
filename
,
tmpdir3
,
format
=
format
)
unpack_archive
(
converter
(
filename
),
converter
(
tmpdir3
)
,
format
=
format
)
self
.
assertEqual
(
rlistdir
(
tmpdir3
),
expected
)
self
.
assertRaises
(
shutil
.
ReadError
,
unpack_archive
,
TESTFN
)
self
.
assertRaises
(
ValueError
,
unpack_archive
,
TESTFN
,
format
=
'xxx'
)
self
.
assertRaises
(
shutil
.
ReadError
,
unpack_archive
,
converter
(
TESTFN
)
)
self
.
assertRaises
(
ValueError
,
unpack_archive
,
converter
(
TESTFN
)
,
format
=
'xxx'
)
def
test_unpack_archive_tar
(
self
):
self
.
check_unpack_archive
(
'tar'
)
...
...
Misc/NEWS
Dosyayı görüntüle @
a12df7b7
...
...
@@ -362,6 +362,9 @@ Library
Fixed
possible
other
errors
caused
by
not
checking
results
of
PyObject_Size
(),
PySequence_Size
(),
or
PyMapping_Size
().
-
bpo
-
30218
:
Fix
PathLike
support
for
shutil
.
unpack_archive
.
Patch
by
Jelle
Zijlstra
.
-
bpo
-
10076
:
Compiled
regular
expression
and
match
objects
in
the
re
module
now
support
copy
.
copy
()
and
copy
.
deepcopy
()
(
they
are
considered
atomic
).
...
...
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