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
b3260f08
Kaydet (Commit)
b3260f08
authored
May 01, 2012
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Detect unsupported compression types.
üst
f6b16a4b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
2 deletions
+30
-2
test_zipfile.py
Lib/test/test_zipfile.py
+11
-0
zipfile.py
Lib/zipfile.py
+19
-2
No files found.
Lib/test/test_zipfile.py
Dosyayı görüntüle @
b3260f08
...
...
@@ -992,6 +992,17 @@ class OtherTests(unittest.TestCase):
caught."""
self
.
assertRaises
(
RuntimeError
,
zipfile
.
ZipFile
,
TESTFN
,
"w"
,
-
1
)
def
test_unsupported_compression
(
self
):
# data is declared as shrunk, but actually deflated
data
=
(
b
'PK
\x03\x04
.
\x00\x00\x00\x01\x00\xe4
C
\xa1
@
\x00\x00\x00
'
b
'
\x00\x02\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00
x
\x03\x00
PK
\x01
'
b
'
\x02
.
\x03
.
\x00\x00\x00\x01\x00\xe4
C
\xa1
@
\x00\x00\x00\x00\x02\x00\x00
'
b
'
\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
'
b
'
\x80\x01\x00\x00\x00\x00
xPK
\x05\x06\x00\x00\x00\x00\x01\x00\x01\x00
'
b
'/
\x00\x00\x00
!
\x00\x00\x00\x00\x00
'
)
with
zipfile
.
ZipFile
(
io
.
BytesIO
(
data
),
'r'
)
as
zipf
:
self
.
assertRaises
(
NotImplementedError
,
zipf
.
open
,
'x'
)
def
test_null_byte_in_filename
(
self
):
"""Check that a filename containing a null byte is properly
terminated."""
...
...
Lib/zipfile.py
Dosyayı görüntüle @
b3260f08
...
...
@@ -504,12 +504,29 @@ def _get_compressor(compress_type):
def
_get_decompressor
(
compress_type
):
if
compress_type
==
ZIP_DEFLATED
:
if
compress_type
==
ZIP_STORED
:
return
None
elif
compress_type
==
ZIP_DEFLATED
:
return
zlib
.
decompressobj
(
-
15
)
elif
compress_type
==
ZIP_BZIP2
:
return
bz2
.
BZ2Decompressor
()
else
:
return
None
unknown_compressors
=
{
1
:
'shrink'
,
2
:
'reduce'
,
3
:
'reduce'
,
4
:
'reduce'
,
5
:
'reduce'
,
6
:
'implode'
,
9
:
'enhanced deflate'
,
10
:
'implode'
,
14
:
'lzma'
,
}
descr
=
unknown_compressors
.
get
(
compress_type
)
if
descr
:
raise
NotImplementedError
(
"compression type
%
d (
%
s)"
%
(
compress_type
,
descr
))
else
:
raise
NotImplementedError
(
"compression type
%
d"
%
(
compress_type
,))
class
ZipExtFile
(
io
.
BufferedIOBase
):
...
...
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