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
4f76fb16
Kaydet (Commit)
4f76fb16
authored
Ock 13, 2017
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #29210: Removed support of deprecated argument "exclude" in
tarfile.TarFile.add().
üst
62db0db5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
49 deletions
+11
-49
tarfile.rst
Doc/library/tarfile.rst
+2
-9
3.7.rst
Doc/whatsnew/3.7.rst
+3
-0
tarfile.py
Lib/tarfile.py
+3
-13
test_tarfile.py
Lib/test/test_tarfile.py
+0
-27
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/tarfile.rst
Dosyayı görüntüle @
4f76fb16
...
@@ -429,16 +429,13 @@ be finalized; only the internally used file object will be closed. See the
...
@@ -429,16 +429,13 @@ be finalized; only the internally used file object will be closed. See the
Return an :class:`io.BufferedReader` object.
Return an :class:`io.BufferedReader` object.
.. method:: TarFile.add(name, arcname=None, recursive=True,
exclude=None,
*, filter=None)
.. method:: TarFile.add(name, arcname=None, recursive=True, *, filter=None)
Add the file *name* to the archive. *name* may be any type of file
Add the file *name* to the archive. *name* may be any type of file
(directory, fifo, symbolic link, etc.). If given, *arcname* specifies an
(directory, fifo, symbolic link, etc.). If given, *arcname* specifies an
alternative name for the file in the archive. Directories are added
alternative name for the file in the archive. Directories are added
recursively by default. This can be avoided by setting *recursive* to
recursively by default. This can be avoided by setting *recursive* to
:const:`False`. If *exclude* is given, it must be a function that takes one
:const:`False`. If *filter* is given, it
filename argument and returns a boolean value. Depending on this value the
respective file is either excluded (:const:`True`) or added
(:const:`False`). If *filter* is specified it must be a keyword argument. It
should be a function that takes a :class:`TarInfo` object argument and
should be a function that takes a :class:`TarInfo` object argument and
returns the changed :class:`TarInfo` object. If it instead returns
returns the changed :class:`TarInfo` object. If it instead returns
:const:`None` the :class:`TarInfo` object will be excluded from the
:const:`None` the :class:`TarInfo` object will be excluded from the
...
@@ -447,10 +444,6 @@ be finalized; only the internally used file object will be closed. See the
...
@@ -447,10 +444,6 @@ be finalized; only the internally used file object will be closed. See the
.. versionchanged:: 3.2
.. versionchanged:: 3.2
Added the *filter* parameter.
Added the *filter* parameter.
.. deprecated:: 3.2
The *exclude* parameter is deprecated, please use the *filter* parameter
instead.
.. method:: TarFile.addfile(tarinfo, fileobj=None)
.. method:: TarFile.addfile(tarinfo, fileobj=None)
...
...
Doc/whatsnew/3.7.rst
Dosyayı görüntüle @
4f76fb16
...
@@ -139,6 +139,9 @@ API and Feature Removals
...
@@ -139,6 +139,9 @@ API and Feature Removals
* Unknown escapes consisting of ``'\'`` and an ASCII letter in replacement
* Unknown escapes consisting of ``'\'`` and an ASCII letter in replacement
templates for :func:`re.sub` will now cause an error.
templates for :func:`re.sub` will now cause an error.
* Removed support of the *exclude* argument in :meth:`tarfile.TarFile.add`.
Use the *filter* argument instead.
Porting to Python 3.7
Porting to Python 3.7
=====================
=====================
...
...
Lib/tarfile.py
Dosyayı görüntüle @
4f76fb16
...
@@ -1897,13 +1897,12 @@ class TarFile(object):
...
@@ -1897,13 +1897,12 @@ class TarFile(object):
_safe_print
(
"link to "
+
tarinfo
.
linkname
)
_safe_print
(
"link to "
+
tarinfo
.
linkname
)
print
()
print
()
def
add
(
self
,
name
,
arcname
=
None
,
recursive
=
True
,
exclude
=
None
,
*
,
filter
=
None
):
def
add
(
self
,
name
,
arcname
=
None
,
recursive
=
True
,
*
,
filter
=
None
):
"""Add the file `name' to the archive. `name' may be any type of file
"""Add the file `name' to the archive. `name' may be any type of file
(directory, fifo, symbolic link, etc.). If given, `arcname'
(directory, fifo, symbolic link, etc.). If given, `arcname'
specifies an alternative name for the file in the archive.
specifies an alternative name for the file in the archive.
Directories are added recursively by default. This can be avoided by
Directories are added recursively by default. This can be avoided by
setting `recursive' to False. `exclude' is a function that should
setting `recursive' to False. `filter' is a function
return True for each filename to be excluded. `filter' is a function
that expects a TarInfo object argument and returns the changed
that expects a TarInfo object argument and returns the changed
TarInfo object, if it returns None the TarInfo object will be
TarInfo object, if it returns None the TarInfo object will be
excluded from the archive.
excluded from the archive.
...
@@ -1913,15 +1912,6 @@ class TarFile(object):
...
@@ -1913,15 +1912,6 @@ class TarFile(object):
if
arcname
is
None
:
if
arcname
is
None
:
arcname
=
name
arcname
=
name
# Exclude pathnames.
if
exclude
is
not
None
:
import
warnings
warnings
.
warn
(
"use the filter argument instead"
,
DeprecationWarning
,
2
)
if
exclude
(
name
):
self
.
_dbg
(
2
,
"tarfile: Excluded
%
r"
%
name
)
return
# Skip if somebody tries to archive the archive...
# Skip if somebody tries to archive the archive...
if
self
.
name
is
not
None
and
os
.
path
.
abspath
(
name
)
==
self
.
name
:
if
self
.
name
is
not
None
and
os
.
path
.
abspath
(
name
)
==
self
.
name
:
self
.
_dbg
(
2
,
"tarfile: Skipped
%
r"
%
name
)
self
.
_dbg
(
2
,
"tarfile: Skipped
%
r"
%
name
)
...
@@ -1953,7 +1943,7 @@ class TarFile(object):
...
@@ -1953,7 +1943,7 @@ class TarFile(object):
if
recursive
:
if
recursive
:
for
f
in
os
.
listdir
(
name
):
for
f
in
os
.
listdir
(
name
):
self
.
add
(
os
.
path
.
join
(
name
,
f
),
os
.
path
.
join
(
arcname
,
f
),
self
.
add
(
os
.
path
.
join
(
name
,
f
),
os
.
path
.
join
(
arcname
,
f
),
recursive
,
exclude
,
filter
=
filter
)
recursive
,
filter
=
filter
)
else
:
else
:
self
.
addfile
(
tarinfo
)
self
.
addfile
(
tarinfo
)
...
...
Lib/test/test_tarfile.py
Dosyayı görüntüle @
4f76fb16
...
@@ -1145,33 +1145,6 @@ class WriteTest(WriteTestBase, unittest.TestCase):
...
@@ -1145,33 +1145,6 @@ class WriteTest(WriteTestBase, unittest.TestCase):
finally
:
finally
:
tar
.
close
()
tar
.
close
()
def
test_exclude
(
self
):
tempdir
=
os
.
path
.
join
(
TEMPDIR
,
"exclude"
)
os
.
mkdir
(
tempdir
)
try
:
for
name
in
(
"foo"
,
"bar"
,
"baz"
):
name
=
os
.
path
.
join
(
tempdir
,
name
)
support
.
create_empty_file
(
name
)
exclude
=
os
.
path
.
isfile
tar
=
tarfile
.
open
(
tmpname
,
self
.
mode
,
encoding
=
"iso8859-1"
)
try
:
with
support
.
check_warnings
((
"use the filter argument"
,
DeprecationWarning
)):
tar
.
add
(
tempdir
,
arcname
=
"empty_dir"
,
exclude
=
exclude
)
finally
:
tar
.
close
()
tar
=
tarfile
.
open
(
tmpname
,
"r"
)
try
:
self
.
assertEqual
(
len
(
tar
.
getmembers
()),
1
)
self
.
assertEqual
(
tar
.
getnames
()[
0
],
"empty_dir"
)
finally
:
tar
.
close
()
finally
:
support
.
rmtree
(
tempdir
)
def
test_filter
(
self
):
def
test_filter
(
self
):
tempdir
=
os
.
path
.
join
(
TEMPDIR
,
"filter"
)
tempdir
=
os
.
path
.
join
(
TEMPDIR
,
"filter"
)
os
.
mkdir
(
tempdir
)
os
.
mkdir
(
tempdir
)
...
...
Misc/NEWS
Dosyayı görüntüle @
4f76fb16
...
@@ -212,6 +212,9 @@ Core and Builtins
...
@@ -212,6 +212,9 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
29210
:
Removed
support
of
deprecated
argument
"exclude"
in
tarfile
.
TarFile
.
add
().
-
Issue
#
29219
:
Fixed
infinite
recursion
in
the
repr
of
uninitialized
-
Issue
#
29219
:
Fixed
infinite
recursion
in
the
repr
of
uninitialized
ctypes
.
CDLL
instances
.
ctypes
.
CDLL
instances
.
...
...
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