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
61e2493b
Commit
61e2493b
authored
Feb 12, 2014
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #17671: Fixed a crash when use non-initialized io.BufferedRWPair.
Based on patch by Stephen Tu.
parent
1f9d11b9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
2 deletions
+48
-2
Lib/test/test_io.py
Lib/test/test_io.py
+38
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_io/bufferedio.c
Modules/_io/bufferedio.c
+7
-2
No files found.
Lib/test/test_io.py
View file @
61e2493b
...
@@ -846,6 +846,16 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests):
...
@@ -846,6 +846,16 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests):
bufio
.
__init__
(
rawio
)
bufio
.
__init__
(
rawio
)
self
.
assertEqual
(
b"abc"
,
bufio
.
read
())
self
.
assertEqual
(
b"abc"
,
bufio
.
read
())
def
test_uninitialized
(
self
):
bufio
=
self
.
tp
.
__new__
(
self
.
tp
)
del
bufio
bufio
=
self
.
tp
.
__new__
(
self
.
tp
)
self
.
assertRaisesRegex
((
ValueError
,
AttributeError
),
'uninitialized|has no attribute'
,
bufio
.
read
,
0
)
bufio
.
__init__
(
self
.
MockRawIO
())
self
.
assertEqual
(
bufio
.
read
(
0
),
b''
)
def
test_read
(
self
):
def
test_read
(
self
):
for
arg
in
(
None
,
7
):
for
arg
in
(
None
,
7
):
rawio
=
self
.
MockRawIO
((
b"abc"
,
b"d"
,
b"efg"
))
rawio
=
self
.
MockRawIO
((
b"abc"
,
b"d"
,
b"efg"
))
...
@@ -1096,6 +1106,16 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests):
...
@@ -1096,6 +1106,16 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests):
bufio
.
flush
()
bufio
.
flush
()
self
.
assertEqual
(
b""
.
join
(
rawio
.
_write_stack
),
b"abcghi"
)
self
.
assertEqual
(
b""
.
join
(
rawio
.
_write_stack
),
b"abcghi"
)
def
test_uninitialized
(
self
):
bufio
=
self
.
tp
.
__new__
(
self
.
tp
)
del
bufio
bufio
=
self
.
tp
.
__new__
(
self
.
tp
)
self
.
assertRaisesRegex
((
ValueError
,
AttributeError
),
'uninitialized|has no attribute'
,
bufio
.
write
,
b''
)
bufio
.
__init__
(
self
.
MockRawIO
())
self
.
assertEqual
(
bufio
.
write
(
b''
),
0
)
def
test_detach_flush
(
self
):
def
test_detach_flush
(
self
):
raw
=
self
.
MockRawIO
()
raw
=
self
.
MockRawIO
()
buf
=
self
.
tp
(
raw
)
buf
=
self
.
tp
(
raw
)
...
@@ -1379,6 +1399,20 @@ class BufferedRWPairTest(unittest.TestCase):
...
@@ -1379,6 +1399,20 @@ class BufferedRWPairTest(unittest.TestCase):
pair
=
self
.
tp
(
self
.
MockRawIO
(),
self
.
MockRawIO
())
pair
=
self
.
tp
(
self
.
MockRawIO
(),
self
.
MockRawIO
())
self
.
assertFalse
(
pair
.
closed
)
self
.
assertFalse
(
pair
.
closed
)
def
test_uninitialized
(
self
):
pair
=
self
.
tp
.
__new__
(
self
.
tp
)
del
pair
pair
=
self
.
tp
.
__new__
(
self
.
tp
)
self
.
assertRaisesRegex
((
ValueError
,
AttributeError
),
'uninitialized|has no attribute'
,
pair
.
read
,
0
)
self
.
assertRaisesRegex
((
ValueError
,
AttributeError
),
'uninitialized|has no attribute'
,
pair
.
write
,
b''
)
pair
.
__init__
(
self
.
MockRawIO
(),
self
.
MockRawIO
())
self
.
assertEqual
(
pair
.
read
(
0
),
b''
)
self
.
assertEqual
(
pair
.
write
(
b''
),
0
)
def
test_detach
(
self
):
def
test_detach
(
self
):
pair
=
self
.
tp
(
self
.
MockRawIO
(),
self
.
MockRawIO
())
pair
=
self
.
tp
(
self
.
MockRawIO
(),
self
.
MockRawIO
())
self
.
assertRaises
(
self
.
UnsupportedOperation
,
pair
.
detach
)
self
.
assertRaises
(
self
.
UnsupportedOperation
,
pair
.
detach
)
...
@@ -1505,6 +1539,10 @@ class BufferedRandomTest(BufferedReaderTest, BufferedWriterTest):
...
@@ -1505,6 +1539,10 @@ class BufferedRandomTest(BufferedReaderTest, BufferedWriterTest):
BufferedReaderTest
.
test_constructor
(
self
)
BufferedReaderTest
.
test_constructor
(
self
)
BufferedWriterTest
.
test_constructor
(
self
)
BufferedWriterTest
.
test_constructor
(
self
)
def
test_uninitialized
(
self
):
BufferedReaderTest
.
test_uninitialized
(
self
)
BufferedWriterTest
.
test_uninitialized
(
self
)
def
test_read_and_write
(
self
):
def
test_read_and_write
(
self
):
raw
=
self
.
MockRawIO
((
b"asdf"
,
b"ghjk"
))
raw
=
self
.
MockRawIO
((
b"asdf"
,
b"ghjk"
))
rw
=
self
.
tp
(
raw
,
8
)
rw
=
self
.
tp
(
raw
,
8
)
...
...
Misc/NEWS
View file @
61e2493b
...
@@ -20,6 +20,9 @@ Core and Builtins
...
@@ -20,6 +20,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #17671: Fixed a crash when use non-initialized io.BufferedRWPair.
Based on patch by Stephen Tu.
- Issue #20594: Avoid name clash with the libc function posix_close.
- Issue #20594: Avoid name clash with the libc function posix_close.
- Issue #19856: shutil.move() failed to move a directory to other directory
- Issue #19856: shutil.move() failed to move a directory to other directory
...
...
Modules/_io/bufferedio.c
View file @
61e2493b
...
@@ -2263,9 +2263,14 @@ bufferedrwpair_dealloc(rwpair *self)
...
@@ -2263,9 +2263,14 @@ bufferedrwpair_dealloc(rwpair *self)
static
PyObject
*
static
PyObject
*
_forward_call
(
buffered
*
self
,
_Py_Identifier
*
name
,
PyObject
*
args
)
_forward_call
(
buffered
*
self
,
_Py_Identifier
*
name
,
PyObject
*
args
)
{
{
PyObject
*
func
=
_PyObject_GetAttrId
((
PyObject
*
)
self
,
name
);
PyObject
*
func
,
*
ret
;
PyObject
*
ret
;
if
(
self
==
NULL
)
{
PyErr_SetString
(
PyExc_ValueError
,
"I/O operation on uninitialized object"
);
return
NULL
;
}
func
=
_PyObject_GetAttrId
((
PyObject
*
)
self
,
name
);
if
(
func
==
NULL
)
{
if
(
func
==
NULL
)
{
PyErr_SetString
(
PyExc_AttributeError
,
name
->
string
);
PyErr_SetString
(
PyExc_AttributeError
,
name
->
string
);
return
NULL
;
return
NULL
;
...
...
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