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
1d19f97e
Kaydet (Commit)
1d19f97e
authored
Şub 12, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #17671: Fixed a crash when use non-initialized io.BufferedRWPair.
Based on patch by Stephen Tu.
üst
ee09d7c0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
2 deletions
+48
-2
test_io.py
Lib/test/test_io.py
+38
-0
NEWS
Misc/NEWS
+3
-0
bufferedio.c
Modules/_io/bufferedio.c
+7
-2
No files found.
Lib/test/test_io.py
Dosyayı görüntüle @
1d19f97e
...
...
@@ -793,6 +793,16 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests):
bufio
.
__init__
(
rawio
)
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
.
assertRaisesRegexp
((
ValueError
,
AttributeError
),
'uninitialized|has no attribute'
,
bufio
.
read
,
0
)
bufio
.
__init__
(
self
.
MockRawIO
())
self
.
assertEqual
(
bufio
.
read
(
0
),
b
''
)
def
test_read
(
self
):
for
arg
in
(
None
,
7
):
rawio
=
self
.
MockRawIO
((
b
"abc"
,
b
"d"
,
b
"efg"
))
...
...
@@ -1029,6 +1039,16 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests):
bufio
.
flush
()
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
.
assertRaisesRegexp
((
ValueError
,
AttributeError
),
'uninitialized|has no attribute'
,
bufio
.
write
,
b
''
)
bufio
.
__init__
(
self
.
MockRawIO
())
self
.
assertEqual
(
bufio
.
write
(
b
''
),
0
)
def
test_detach_flush
(
self
):
raw
=
self
.
MockRawIO
()
buf
=
self
.
tp
(
raw
)
...
...
@@ -1313,6 +1333,20 @@ class BufferedRWPairTest(unittest.TestCase):
pair
=
self
.
tp
(
self
.
MockRawIO
(),
self
.
MockRawIO
())
self
.
assertFalse
(
pair
.
closed
)
def
test_uninitialized
(
self
):
pair
=
self
.
tp
.
__new__
(
self
.
tp
)
del
pair
pair
=
self
.
tp
.
__new__
(
self
.
tp
)
self
.
assertRaisesRegexp
((
ValueError
,
AttributeError
),
'uninitialized|has no attribute'
,
pair
.
read
,
0
)
self
.
assertRaisesRegexp
((
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
):
pair
=
self
.
tp
(
self
.
MockRawIO
(),
self
.
MockRawIO
())
self
.
assertRaises
(
self
.
UnsupportedOperation
,
pair
.
detach
)
...
...
@@ -1440,6 +1474,10 @@ class BufferedRandomTest(BufferedReaderTest, BufferedWriterTest):
BufferedReaderTest
.
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
):
raw
=
self
.
MockRawIO
((
b
"asdf"
,
b
"ghjk"
))
rw
=
self
.
tp
(
raw
,
8
)
...
...
Misc/NEWS
Dosyayı görüntüle @
1d19f97e
...
...
@@ -44,6 +44,9 @@ Core and Builtins
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 #19856: shutil.move() failed to move a directory to other directory
...
...
Modules/_io/bufferedio.c
Dosyayı görüntüle @
1d19f97e
...
...
@@ -2129,9 +2129,14 @@ bufferedrwpair_dealloc(rwpair *self)
static
PyObject
*
_forward_call
(
buffered
*
self
,
const
char
*
name
,
PyObject
*
args
)
{
PyObject
*
func
=
PyObject_GetAttrString
((
PyObject
*
)
self
,
name
);
PyObject
*
ret
;
PyObject
*
func
,
*
ret
;
if
(
self
==
NULL
)
{
PyErr_SetString
(
PyExc_ValueError
,
"I/O operation on uninitialized object"
);
return
NULL
;
}
func
=
PyObject_GetAttrString
((
PyObject
*
)
self
,
name
);
if
(
func
==
NULL
)
{
PyErr_SetString
(
PyExc_AttributeError
,
name
);
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