Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ab25c7c0
Commit
ab25c7c0
authored
Sep 27, 2013
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Plain Diff
Issue #19053: ZipExtFile.read1() with non-zero argument no more returns empty
bytes until end of data.
parents
cb2c4fe6
d2c07a58
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
8 deletions
+57
-8
Lib/test/test_zipfile.py
Lib/test/test_zipfile.py
+39
-0
Lib/zipfile.py
Lib/zipfile.py
+15
-8
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_zipfile.py
View file @
ab25c7c0
...
...
@@ -158,6 +158,45 @@ class AbstractTestsWithSourceFile:
for
f
in
get_files
(
self
):
self
.
zip_random_open_test
(
f
,
self
.
compression
)
def
zip_read1_test
(
self
,
f
,
compression
):
self
.
make_test_archive
(
f
,
compression
)
# Read the ZIP archive
with
zipfile
.
ZipFile
(
f
,
"r"
)
as
zipfp
,
\
zipfp
.
open
(
TESTFN
)
as
zipopen
:
zipdata
=
[]
while
True
:
read_data
=
zipopen
.
read1
(
-
1
)
if
not
read_data
:
break
zipdata
.
append
(
read_data
)
self
.
assertEqual
(
b''
.
join
(
zipdata
),
self
.
data
)
def
test_read1
(
self
):
for
f
in
get_files
(
self
):
self
.
zip_read1_test
(
f
,
self
.
compression
)
def
zip_read1_10_test
(
self
,
f
,
compression
):
self
.
make_test_archive
(
f
,
compression
)
# Read the ZIP archive
with
zipfile
.
ZipFile
(
f
,
"r"
)
as
zipfp
,
\
zipfp
.
open
(
TESTFN
)
as
zipopen
:
zipdata
=
[]
while
True
:
read_data
=
zipopen
.
read1
(
10
)
self
.
assertLessEqual
(
len
(
read_data
),
10
)
if
not
read_data
:
break
zipdata
.
append
(
read_data
)
self
.
assertEqual
(
b''
.
join
(
zipdata
),
self
.
data
)
def
test_read1_10
(
self
):
for
f
in
get_files
(
self
):
self
.
zip_read1_10_test
(
f
,
self
.
compression
)
def
zip_readline_read_test
(
self
,
f
,
compression
):
self
.
make_test_archive
(
f
,
compression
)
...
...
Lib/zipfile.py
View file @
ab25c7c0
...
...
@@ -785,8 +785,11 @@ class ZipExtFile(io.BufferedIOBase):
buf
=
self
.
_readbuffer
[
self
.
_offset
:]
self
.
_readbuffer
=
b''
self
.
_offset
=
0
data
=
self
.
_read1
(
self
.
MAX_N
)
buf
+=
data
while
not
self
.
_eof
:
data
=
self
.
_read1
(
self
.
MAX_N
)
if
data
:
buf
+=
data
break
return
buf
end
=
n
+
self
.
_offset
...
...
@@ -800,12 +803,16 @@ class ZipExtFile(io.BufferedIOBase):
self
.
_readbuffer
=
b''
self
.
_offset
=
0
if
n
>
0
:
data
=
self
.
_read1
(
n
)
if
n
<
len
(
data
):
self
.
_readbuffer
=
data
self
.
_offset
=
n
data
=
data
[:
n
]
buf
+=
data
while
not
self
.
_eof
:
data
=
self
.
_read1
(
n
)
if
n
<
len
(
data
):
self
.
_readbuffer
=
data
self
.
_offset
=
n
buf
+=
data
[:
n
]
break
if
data
:
buf
+=
data
break
return
buf
def
_read1
(
self
,
n
):
...
...
Misc/NEWS
View file @
ab25c7c0
...
...
@@ -15,6 +15,9 @@ Core and Builtins
Library
-------
-
Issue
#
19053
:
ZipExtFile
.
read1
()
with
non
-
zero
argument
no
more
returns
empty
bytes
until
end
of
data
.
-
logging
:
added
support
for
Unix
domain
sockets
to
SocketHandler
and
DatagramHandler
.
...
...
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