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
9b7a1a1a
Kaydet (Commit)
9b7a1a1a
authored
Ock 20, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #20262: Warnings are raised now when duplicate names are added in the
ZIP file or too long ZIP file comment is truncated.
üst
7e52705e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
+12
-6
test_zipfile.py
Lib/test/test_zipfile.py
+3
-0
zipfile.py
Lib/zipfile.py
+6
-6
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_zipfile.py
Dosyayı görüntüle @
9b7a1a1a
...
@@ -844,7 +844,9 @@ class OtherTests(unittest.TestCase):
...
@@ -844,7 +844,9 @@ class OtherTests(unittest.TestCase):
# Create the ZIP archive
# Create the ZIP archive
with
zipfile
.
ZipFile
(
TESTFN2
,
"w"
,
zipfile
.
ZIP_STORED
)
as
zipfp
:
with
zipfile
.
ZipFile
(
TESTFN2
,
"w"
,
zipfile
.
ZIP_STORED
)
as
zipfp
:
zipfp
.
writestr
(
"name"
,
"foo"
)
zipfp
.
writestr
(
"name"
,
"foo"
)
with
self
.
assertWarns
(
UserWarning
):
zipfp
.
writestr
(
"name"
,
"bar"
)
zipfp
.
writestr
(
"name"
,
"bar"
)
self
.
assertEqual
(
zipfp
.
namelist
(),
[
"name"
]
*
2
)
with
zipfile
.
ZipFile
(
TESTFN2
,
"r"
)
as
zipfp
:
with
zipfile
.
ZipFile
(
TESTFN2
,
"r"
)
as
zipfp
:
infos
=
zipfp
.
infolist
()
infos
=
zipfp
.
infolist
()
...
@@ -1150,6 +1152,7 @@ class OtherTests(unittest.TestCase):
...
@@ -1150,6 +1152,7 @@ class OtherTests(unittest.TestCase):
# check a comment that is too long is truncated
# check a comment that is too long is truncated
with
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"w"
)
as
zipf
:
with
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"w"
)
as
zipf
:
with
self
.
assertWarns
(
UserWarning
):
zipf
.
comment
=
comment2
+
b
'oops'
zipf
.
comment
=
comment2
+
b
'oops'
zipf
.
writestr
(
"foo.txt"
,
"O, for a Muse of Fire!"
)
zipf
.
writestr
(
"foo.txt"
,
"O, for a Muse of Fire!"
)
with
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"r"
)
as
zipfr
:
with
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"r"
)
as
zipfr
:
...
...
Lib/zipfile.py
Dosyayı görüntüle @
9b7a1a1a
...
@@ -1102,10 +1102,10 @@ class ZipFile:
...
@@ -1102,10 +1102,10 @@ class ZipFile:
if
not
isinstance
(
comment
,
bytes
):
if
not
isinstance
(
comment
,
bytes
):
raise
TypeError
(
"comment: expected bytes, got
%
s"
%
type
(
comment
))
raise
TypeError
(
"comment: expected bytes, got
%
s"
%
type
(
comment
))
# check for valid comment length
# check for valid comment length
if
len
(
comment
)
>
=
ZIP_MAX_COMMENT
:
if
len
(
comment
)
>
ZIP_MAX_COMMENT
:
i
f
self
.
debug
:
i
mport
warnings
print
(
'Archive comment is too long; truncating to
%
d bytes'
warnings
.
warn
(
'Archive comment is too long; truncating to
%
d bytes'
%
ZIP_MAX_COMMENT
)
%
ZIP_MAX_COMMENT
,
stacklevel
=
2
)
comment
=
comment
[:
ZIP_MAX_COMMENT
]
comment
=
comment
[:
ZIP_MAX_COMMENT
]
self
.
_comment
=
comment
self
.
_comment
=
comment
self
.
_didModify
=
True
self
.
_didModify
=
True
...
@@ -1290,8 +1290,8 @@ class ZipFile:
...
@@ -1290,8 +1290,8 @@ class ZipFile:
def
_writecheck
(
self
,
zinfo
):
def
_writecheck
(
self
,
zinfo
):
"""Check for errors before writing a file to the archive."""
"""Check for errors before writing a file to the archive."""
if
zinfo
.
filename
in
self
.
NameToInfo
:
if
zinfo
.
filename
in
self
.
NameToInfo
:
i
f
self
.
debug
:
# Warning for duplicate name
s
i
mport
warning
s
print
(
"Duplicate name:"
,
zinfo
.
filename
)
warnings
.
warn
(
'Duplicate name:
%
r'
%
zinfo
.
filename
,
stacklevel
=
3
)
if
self
.
mode
not
in
(
"w"
,
"a"
):
if
self
.
mode
not
in
(
"w"
,
"a"
):
raise
RuntimeError
(
'write() requires mode "w" or "a"'
)
raise
RuntimeError
(
'write() requires mode "w" or "a"'
)
if
not
self
.
fp
:
if
not
self
.
fp
:
...
...
Misc/NEWS
Dosyayı görüntüle @
9b7a1a1a
...
@@ -43,6 +43,9 @@ Core and Builtins
...
@@ -43,6 +43,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #20262: Warnings are raised now when duplicate names are added in the
ZIP file or too long ZIP file comment is truncated.
- Issue #18574: Added missing newline in 100-Continue reply from
- Issue #18574: Added missing newline in 100-Continue reply from
http.server.BaseHTTPRequestHandler. Patch by Nikolaus Rath.
http.server.BaseHTTPRequestHandler. Patch by Nikolaus Rath.
...
...
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