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
45efb225
Kaydet (Commit)
45efb225
authored
Eyl 23, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #21866: ZipFile.close() no longer writes ZIP64 central directory
records if allowZip64 is false.
üst
7d96a09a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
14 deletions
+63
-14
test_zipfile64.py
Lib/test/test_zipfile64.py
+36
-1
zipfile.py
Lib/zipfile.py
+24
-13
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_zipfile64.py
Dosyayı görüntüle @
45efb225
...
@@ -99,7 +99,7 @@ class OtherTests(unittest.TestCase):
...
@@ -99,7 +99,7 @@ class OtherTests(unittest.TestCase):
def
testMoreThan64kFiles
(
self
):
def
testMoreThan64kFiles
(
self
):
# This test checks that more than 64k files can be added to an archive,
# This test checks that more than 64k files can be added to an archive,
# and that the resulting archive can be read properly by ZipFile
# and that the resulting archive can be read properly by ZipFile
zipf
=
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"w"
)
zipf
=
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"w"
,
allowZip64
=
True
)
zipf
.
debug
=
100
zipf
.
debug
=
100
numfiles
=
(
1
<<
16
)
*
3
/
2
numfiles
=
(
1
<<
16
)
*
3
/
2
for
i
in
xrange
(
numfiles
):
for
i
in
xrange
(
numfiles
):
...
@@ -111,8 +111,43 @@ class OtherTests(unittest.TestCase):
...
@@ -111,8 +111,43 @@ class OtherTests(unittest.TestCase):
self
.
assertEqual
(
len
(
zipf2
.
namelist
()),
numfiles
)
self
.
assertEqual
(
len
(
zipf2
.
namelist
()),
numfiles
)
for
i
in
xrange
(
numfiles
):
for
i
in
xrange
(
numfiles
):
self
.
assertEqual
(
zipf2
.
read
(
"foo
%08
d"
%
i
),
"
%
d"
%
(
i
**
3
%
57
))
self
.
assertEqual
(
zipf2
.
read
(
"foo
%08
d"
%
i
),
"
%
d"
%
(
i
**
3
%
57
))
zipf2
.
close
()
def
testMoreThan64kFilesAppend
(
self
):
zipf
=
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"w"
,
allowZip64
=
False
)
zipf
.
debug
=
100
numfiles
=
(
1
<<
16
)
-
1
for
i
in
range
(
numfiles
):
zipf
.
writestr
(
"foo
%08
d"
%
i
,
"
%
d"
%
(
i
**
3
%
57
))
self
.
assertEqual
(
len
(
zipf
.
namelist
()),
numfiles
)
with
self
.
assertRaises
(
zipfile
.
LargeZipFile
):
zipf
.
writestr
(
"foo
%08
d"
%
numfiles
,
b
''
)
self
.
assertEqual
(
len
(
zipf
.
namelist
()),
numfiles
)
zipf
.
close
()
zipf
=
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"a"
,
allowZip64
=
False
)
zipf
.
debug
=
100
self
.
assertEqual
(
len
(
zipf
.
namelist
()),
numfiles
)
with
self
.
assertRaises
(
zipfile
.
LargeZipFile
):
zipf
.
writestr
(
"foo
%08
d"
%
numfiles
,
b
''
)
self
.
assertEqual
(
len
(
zipf
.
namelist
()),
numfiles
)
zipf
.
close
()
zipf
.
close
()
zipf
=
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"a"
,
allowZip64
=
True
)
zipf
.
debug
=
100
self
.
assertEqual
(
len
(
zipf
.
namelist
()),
numfiles
)
numfiles2
=
(
1
<<
16
)
*
3
//
2
for
i
in
range
(
numfiles
,
numfiles2
):
zipf
.
writestr
(
"foo
%08
d"
%
i
,
"
%
d"
%
(
i
**
3
%
57
))
self
.
assertEqual
(
len
(
zipf
.
namelist
()),
numfiles2
)
zipf
.
close
()
zipf2
=
zipfile
.
ZipFile
(
TESTFN
,
mode
=
"r"
)
self
.
assertEqual
(
len
(
zipf2
.
namelist
()),
numfiles2
)
for
i
in
range
(
numfiles2
):
self
.
assertEqual
(
zipf2
.
read
(
"foo
%08
d"
%
i
),
"
%
d"
%
(
i
**
3
%
57
))
zipf2
.
close
()
def
tearDown
(
self
):
def
tearDown
(
self
):
test_support
.
unlink
(
TESTFN
)
test_support
.
unlink
(
TESTFN
)
test_support
.
unlink
(
TESTFN2
)
test_support
.
unlink
(
TESTFN2
)
...
...
Lib/zipfile.py
Dosyayı görüntüle @
45efb225
...
@@ -30,7 +30,7 @@ class LargeZipFile(Exception):
...
@@ -30,7 +30,7 @@ class LargeZipFile(Exception):
error
=
BadZipfile
# The exception raised by this module
error
=
BadZipfile
# The exception raised by this module
ZIP64_LIMIT
=
(
1
<<
31
)
-
1
ZIP64_LIMIT
=
(
1
<<
31
)
-
1
ZIP_FILECOUNT_LIMIT
=
1
<<
16
ZIP_FILECOUNT_LIMIT
=
(
1
<<
16
)
-
1
ZIP_MAX_COMMENT
=
(
1
<<
16
)
-
1
ZIP_MAX_COMMENT
=
(
1
<<
16
)
-
1
# constants for Zip file compression methods
# constants for Zip file compression methods
...
@@ -1101,12 +1101,17 @@ class ZipFile(object):
...
@@ -1101,12 +1101,17 @@ class ZipFile(object):
if
zinfo
.
compress_type
not
in
(
ZIP_STORED
,
ZIP_DEFLATED
):
if
zinfo
.
compress_type
not
in
(
ZIP_STORED
,
ZIP_DEFLATED
):
raise
RuntimeError
,
\
raise
RuntimeError
,
\
"That compression method is not supported"
"That compression method is not supported"
if
zinfo
.
file_size
>
ZIP64_LIMIT
:
if
not
self
.
_allowZip64
:
if
not
self
.
_allowZip64
:
requires_zip64
=
None
raise
LargeZipFile
(
"Filesize would require ZIP64 extensions"
)
if
len
(
self
.
filelist
)
>=
ZIP_FILECOUNT_LIMIT
:
if
zinfo
.
header_offset
>
ZIP64_LIMIT
:
requires_zip64
=
"Files count"
if
not
self
.
_allowZip64
:
elif
zinfo
.
file_size
>
ZIP64_LIMIT
:
raise
LargeZipFile
(
"Zipfile size would require ZIP64 extensions"
)
requires_zip64
=
"Filesize"
elif
zinfo
.
header_offset
>
ZIP64_LIMIT
:
requires_zip64
=
"Zipfile size"
if
requires_zip64
:
raise
LargeZipFile
(
requires_zip64
+
" would require ZIP64 extensions"
)
def
write
(
self
,
filename
,
arcname
=
None
,
compress_type
=
None
):
def
write
(
self
,
filename
,
arcname
=
None
,
compress_type
=
None
):
"""Put the bytes from filename into the archive under the name
"""Put the bytes from filename into the archive under the name
...
@@ -1256,10 +1261,8 @@ class ZipFile(object):
...
@@ -1256,10 +1261,8 @@ class ZipFile(object):
try
:
try
:
if
self
.
mode
in
(
"w"
,
"a"
)
and
self
.
_didModify
:
# write ending records
if
self
.
mode
in
(
"w"
,
"a"
)
and
self
.
_didModify
:
# write ending records
count
=
0
pos1
=
self
.
fp
.
tell
()
pos1
=
self
.
fp
.
tell
()
for
zinfo
in
self
.
filelist
:
# write central directory
for
zinfo
in
self
.
filelist
:
# write central directory
count
=
count
+
1
dt
=
zinfo
.
date_time
dt
=
zinfo
.
date_time
dosdate
=
(
dt
[
0
]
-
1980
)
<<
9
|
dt
[
1
]
<<
5
|
dt
[
2
]
dosdate
=
(
dt
[
0
]
-
1980
)
<<
9
|
dt
[
1
]
<<
5
|
dt
[
2
]
dostime
=
dt
[
3
]
<<
11
|
dt
[
4
]
<<
5
|
(
dt
[
5
]
//
2
)
dostime
=
dt
[
3
]
<<
11
|
dt
[
4
]
<<
5
|
(
dt
[
5
]
//
2
)
...
@@ -1320,13 +1323,21 @@ class ZipFile(object):
...
@@ -1320,13 +1323,21 @@ class ZipFile(object):
pos2
=
self
.
fp
.
tell
()
pos2
=
self
.
fp
.
tell
()
# Write end-of-zip-archive record
# Write end-of-zip-archive record
centDirCount
=
count
centDirCount
=
len
(
self
.
filelist
)
centDirSize
=
pos2
-
pos1
centDirSize
=
pos2
-
pos1
centDirOffset
=
pos1
centDirOffset
=
pos1
if
(
centDirCount
>=
ZIP_FILECOUNT_LIMIT
or
requires_zip64
=
None
centDirOffset
>
ZIP64_LIMIT
or
if
centDirCount
>
ZIP_FILECOUNT_LIMIT
:
centDirSize
>
ZIP64_LIMIT
):
requires_zip64
=
"Files count"
elif
centDirOffset
>
ZIP64_LIMIT
:
requires_zip64
=
"Central directory offset"
elif
centDirSize
>
ZIP64_LIMIT
:
requires_zip64
=
"Central directory size"
if
requires_zip64
:
# Need to write the ZIP64 end-of-archive records
# Need to write the ZIP64 end-of-archive records
if
not
self
.
_allowZip64
:
raise
LargeZipFile
(
requires_zip64
+
" would require ZIP64 extensions"
)
zip64endrec
=
struct
.
pack
(
zip64endrec
=
struct
.
pack
(
structEndArchive64
,
stringEndArchive64
,
structEndArchive64
,
stringEndArchive64
,
44
,
45
,
45
,
0
,
0
,
centDirCount
,
centDirCount
,
44
,
45
,
45
,
0
,
0
,
centDirCount
,
centDirCount
,
...
...
Misc/NEWS
Dosyayı görüntüle @
45efb225
...
@@ -22,6 +22,9 @@ Core and Builtins
...
@@ -22,6 +22,9 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
21866
:
ZipFile
.
close
()
no
longer
writes
ZIP64
central
directory
records
if
allowZip64
is
false
.
-
Issue
#
22415
:
Fixed
debugging
output
of
the
GROUPREF_EXISTS
opcode
in
the
re
-
Issue
#
22415
:
Fixed
debugging
output
of
the
GROUPREF_EXISTS
opcode
in
the
re
module
.
module
.
...
...
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