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
a80987f2
Commit
a80987f2
authored
May 25, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #12175: RawIOBase.readall() now returns None if read() returns None.
parent
b79f28cc
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
3 deletions
+20
-3
Lib/_pyio.py
Lib/_pyio.py
+5
-1
Lib/test/test_io.py
Lib/test/test_io.py
+5
-2
Misc/NEWS
Misc/NEWS
+2
-0
Modules/_io/iobase.c
Modules/_io/iobase.c
+8
-0
No files found.
Lib/_pyio.py
View file @
a80987f2
...
@@ -556,7 +556,11 @@ class RawIOBase(IOBase):
...
@@ -556,7 +556,11 @@ class RawIOBase(IOBase):
if
not
data
:
if
not
data
:
break
break
res
+=
data
res
+=
data
if
res
:
return
bytes
(
res
)
return
bytes
(
res
)
else
:
# b'' or None
return
data
def
readinto
(
self
,
b
):
def
readinto
(
self
,
b
):
"""Read up to len(b) bytes into b.
"""Read up to len(b) bytes into b.
...
...
Lib/test/test_io.py
View file @
a80987f2
...
@@ -790,14 +790,17 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests):
...
@@ -790,14 +790,17 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests):
# Inject some None's in there to simulate EWOULDBLOCK
# Inject some None's in there to simulate EWOULDBLOCK
rawio
=
self
.
MockRawIO
((
b"abc"
,
b"d"
,
None
,
b"efg"
,
None
,
None
,
None
))
rawio
=
self
.
MockRawIO
((
b"abc"
,
b"d"
,
None
,
b"efg"
,
None
,
None
,
None
))
bufio
=
self
.
tp
(
rawio
)
bufio
=
self
.
tp
(
rawio
)
self
.
assertEqual
(
b"abcd"
,
bufio
.
read
(
6
))
self
.
assertEqual
(
b"abcd"
,
bufio
.
read
(
6
))
self
.
assertEqual
(
b"e"
,
bufio
.
read
(
1
))
self
.
assertEqual
(
b"e"
,
bufio
.
read
(
1
))
self
.
assertEqual
(
b"fg"
,
bufio
.
read
())
self
.
assertEqual
(
b"fg"
,
bufio
.
read
())
self
.
assertEqual
(
b""
,
bufio
.
peek
(
1
))
self
.
assertEqual
(
b""
,
bufio
.
peek
(
1
))
self
.
assert
True
(
None
is
bufio
.
read
())
self
.
assert
IsNone
(
bufio
.
read
())
self
.
assertEqual
(
b""
,
bufio
.
read
())
self
.
assertEqual
(
b""
,
bufio
.
read
())
rawio
=
self
.
MockRawIO
((
b"a"
,
None
,
None
))
self
.
assertEqual
(
b"a"
,
rawio
.
readall
())
self
.
assertIsNone
(
rawio
.
readall
())
def
test_read_past_eof
(
self
):
def
test_read_past_eof
(
self
):
rawio
=
self
.
MockRawIO
((
b"abc"
,
b"d"
,
b"efg"
))
rawio
=
self
.
MockRawIO
((
b"abc"
,
b"d"
,
b"efg"
))
bufio
=
self
.
tp
(
rawio
)
bufio
=
self
.
tp
(
rawio
)
...
...
Misc/NEWS
View file @
a80987f2
...
@@ -75,6 +75,8 @@ Core and Builtins
...
@@ -75,6 +75,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #12175: RawIOBase.readall() now returns None if read() returns None.
- Issue #12175: FileIO.readall() now raises a ValueError instead of an IOError
- Issue #12175: FileIO.readall() now raises a ValueError instead of an IOError
if the file is closed.
if the file is closed.
...
...
Modules/_io/iobase.c
View file @
a80987f2
...
@@ -814,6 +814,14 @@ rawiobase_readall(PyObject *self, PyObject *args)
...
@@ -814,6 +814,14 @@ rawiobase_readall(PyObject *self, PyObject *args)
Py_DECREF
(
chunks
);
Py_DECREF
(
chunks
);
return
NULL
;
return
NULL
;
}
}
if
(
data
==
Py_None
)
{
if
(
PyList_GET_SIZE
(
chunks
)
==
0
)
{
Py_DECREF
(
chunks
);
return
data
;
}
Py_DECREF
(
data
);
break
;
}
if
(
!
PyBytes_Check
(
data
))
{
if
(
!
PyBytes_Check
(
data
))
{
Py_DECREF
(
chunks
);
Py_DECREF
(
chunks
);
Py_DECREF
(
data
);
Py_DECREF
(
data
);
...
...
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