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
a14f7d23
Kaydet (Commit)
a14f7d23
authored
Ock 26, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #14099: Restored support of writing ZIP files to tellable but
non-seekable streams.
üst
f15e5240
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
3 deletions
+44
-3
test_zipfile.py
Lib/test/test_zipfile.py
+28
-0
zipfile.py
Lib/zipfile.py
+13
-3
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_zipfile.py
Dosyayı görüntüle @
a14f7d23
...
...
@@ -1668,6 +1668,34 @@ class LzmaTestsWithRandomBinaryFiles(AbstractTestsWithRandomBinaryFiles,
compression
=
zipfile
.
ZIP_LZMA
# Privide the tell() method but not seek()
class
Tellable
:
def
__init__
(
self
,
fp
):
self
.
fp
=
fp
self
.
offset
=
0
def
write
(
self
,
data
):
self
.
offset
+=
self
.
fp
.
write
(
data
)
def
tell
(
self
):
return
self
.
offset
def
flush
(
self
):
pass
class
UnseekableTests
(
unittest
.
TestCase
):
def
test_writestr_tellable
(
self
):
f
=
io
.
BytesIO
()
with
zipfile
.
ZipFile
(
Tellable
(
f
),
'w'
,
zipfile
.
ZIP_STORED
)
as
zipfp
:
zipfp
.
writestr
(
'ones'
,
b
'111'
)
zipfp
.
writestr
(
'twos'
,
b
'222'
)
with
zipfile
.
ZipFile
(
f
,
mode
=
'r'
)
as
zipf
:
with
zipf
.
open
(
'ones'
)
as
zopen
:
self
.
assertEqual
(
zopen
.
read
(),
b
'111'
)
with
zipf
.
open
(
'twos'
)
as
zopen
:
self
.
assertEqual
(
zopen
.
read
(),
b
'222'
)
@requires_zlib
class
TestsWithMultipleOpens
(
unittest
.
TestCase
):
@classmethod
...
...
Lib/zipfile.py
Dosyayı görüntüle @
a14f7d23
...
...
@@ -1504,7 +1504,14 @@ class ZipFile:
zinfo
.
file_size
=
len
(
data
)
# Uncompressed size
with
self
.
_lock
:
self
.
fp
.
seek
(
self
.
start_dir
,
0
)
try
:
self
.
fp
.
seek
(
self
.
start_dir
)
except
(
AttributeError
,
io
.
UnsupportedOperation
):
# Some file-like objects can provide tell() but not seek()
pass
zinfo
.
header_offset
=
self
.
fp
.
tell
()
# Start of header data
if
compress_type
is
not
None
:
zinfo
.
compress_type
=
compress_type
zinfo
.
header_offset
=
self
.
fp
.
tell
()
# Start of header data
if
compress_type
is
not
None
:
zinfo
.
compress_type
=
compress_type
...
...
@@ -1550,7 +1557,11 @@ class ZipFile:
try
:
if
self
.
mode
in
(
"w"
,
"a"
)
and
self
.
_didModify
:
# write ending records
with
self
.
_lock
:
self
.
fp
.
seek
(
self
.
start_dir
,
0
)
try
:
self
.
fp
.
seek
(
self
.
start_dir
)
except
(
AttributeError
,
io
.
UnsupportedOperation
):
# Some file-like objects can provide tell() but not seek()
pass
self
.
_write_end_record
()
finally
:
fp
=
self
.
fp
...
...
@@ -1558,7 +1569,6 @@ class ZipFile:
self
.
_fpclose
(
fp
)
def
_write_end_record
(
self
):
self
.
fp
.
seek
(
self
.
start_dir
,
0
)
for
zinfo
in
self
.
filelist
:
# write central directory
dt
=
zinfo
.
date_time
dosdate
=
(
dt
[
0
]
-
1980
)
<<
9
|
dt
[
1
]
<<
5
|
dt
[
2
]
...
...
Misc/NEWS
Dosyayı görüntüle @
a14f7d23
...
...
@@ -218,6 +218,9 @@ Core and Builtins
Library
-------
-
Issue
#
14099
:
Restored
support
of
writing
ZIP
files
to
tellable
but
non
-
seekable
streams
.
-
Issue
#
14099
:
Writing
to
ZipFile
and
reading
multiple
ZipExtFiles
is
threadsafe
now
.
...
...
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