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
5a9112c0
Kaydet (Commit)
5a9112c0
authored
Ock 13, 2010
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #2846: Add support for gzip.GzipFile reading zero-padded files.
Patch by Brian Curtin.
üst
10042922
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
0 deletions
+27
-0
gzip.rst
Doc/library/gzip.rst
+3
-0
gzip.py
Lib/gzip.py
+9
-0
test_gzip.py
Lib/test/test_gzip.py
+12
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/gzip.rst
Dosyayı görüntüle @
5a9112c0
...
@@ -72,6 +72,9 @@ The module defines the following items:
...
@@ -72,6 +72,9 @@ The module defines the following items:
.. versionchanged:: 2.7
.. versionchanged:: 2.7
Support for the :keyword:`with` statement was added.
Support for the :keyword:`with` statement was added.
.. versionchanged:: 2.7
Support for zero-padded files was added.
.. function:: open(filename[, mode[, compresslevel]])
.. function:: open(filename[, mode[, compresslevel]])
...
...
Lib/gzip.py
Dosyayı görüntüle @
5a9112c0
...
@@ -330,6 +330,15 @@ class GzipFile(io.BufferedIOBase):
...
@@ -330,6 +330,15 @@ class GzipFile(io.BufferedIOBase):
elif
isize
!=
(
self
.
size
&
0xffffffff
L
):
elif
isize
!=
(
self
.
size
&
0xffffffff
L
):
raise
IOError
,
"Incorrect length of data produced"
raise
IOError
,
"Incorrect length of data produced"
# Gzip files can be padded with zeroes and still have archives.
# Consume all zero bytes and set the file position to the first
# non-zero byte. See http://www.gzip.org/#faq8
c
=
"
\x00
"
while
c
==
"
\x00
"
:
c
=
self
.
fileobj
.
read
(
1
)
if
c
:
self
.
fileobj
.
seek
(
-
1
,
1
)
@property
@property
def
closed
(
self
):
def
closed
(
self
):
return
self
.
fileobj
is
None
return
self
.
fileobj
is
None
...
...
Lib/test/test_gzip.py
Dosyayı görüntüle @
5a9112c0
...
@@ -252,6 +252,18 @@ class TestGzip(unittest.TestCase):
...
@@ -252,6 +252,18 @@ class TestGzip(unittest.TestCase):
else
:
else
:
self
.
fail
(
"1/0 didn't raise an exception"
)
self
.
fail
(
"1/0 didn't raise an exception"
)
def
test_zero_padded_file
(
self
):
with
gzip
.
GzipFile
(
self
.
filename
,
"wb"
)
as
f
:
f
.
write
(
data1
*
50
)
# Pad the file with zeroes
with
open
(
self
.
filename
,
"ab"
)
as
f
:
f
.
write
(
"
\x00
"
*
50
)
with
gzip
.
GzipFile
(
self
.
filename
,
"rb"
)
as
f
:
d
=
f
.
read
()
self
.
assertEqual
(
d
,
data1
*
50
,
"Incorrect data in file"
)
def
test_main
(
verbose
=
None
):
def
test_main
(
verbose
=
None
):
test_support
.
run_unittest
(
TestGzip
)
test_support
.
run_unittest
(
TestGzip
)
...
...
Misc/NEWS
Dosyayı görüntüle @
5a9112c0
...
@@ -32,6 +32,9 @@ Core and Builtins
...
@@ -32,6 +32,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #2846: Add support for gzip.GzipFile reading zero-padded files.
Patch by Brian Curtin.
- Issue #5827: Make sure that normpath preserves unicode. Initial patch
- Issue #5827: Make sure that normpath preserves unicode. Initial patch
by Matt Giuca.
by Matt Giuca.
...
...
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