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
a5b4ea15
Kaydet (Commit)
a5b4ea15
authored
Agu 25, 2017
tarafından
Oren Milman
Kaydeden (comit)
Serhiy Storchaka
Agu 25, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-31271: Fix an assertion failure in io.TextIOWrapper.write. (#3201)
üst
dce65020
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
0 deletions
+17
-0
test_io.py
Lib/test/test_io.py
+8
-0
2017-08-25-20-43-22.bpo-31271.YMduKF.rst
...ore and Builtins/2017-08-25-20-43-22.bpo-31271.YMduKF.rst
+2
-0
textio.c
Modules/_io/textio.c
+7
-0
No files found.
Lib/test/test_io.py
Dosyayı görüntüle @
a5b4ea15
...
@@ -3225,6 +3225,14 @@ class TextIOWrapperTest(unittest.TestCase):
...
@@ -3225,6 +3225,14 @@ class TextIOWrapperTest(unittest.TestCase):
t
=
self
.
TextIOWrapper
(
self
.
StringIO
(
'a'
))
t
=
self
.
TextIOWrapper
(
self
.
StringIO
(
'a'
))
self
.
assertRaises
(
TypeError
,
t
.
read
)
self
.
assertRaises
(
TypeError
,
t
.
read
)
def
test_illegal_encoder
(
self
):
# Issue 31271: Calling write() while the return value of encoder's
# encode() is invalid shouldn't cause an assertion failure.
rot13
=
codecs
.
lookup
(
"rot13"
)
with
support
.
swap_attr
(
rot13
,
'_is_text_encoding'
,
True
):
t
=
io
.
TextIOWrapper
(
io
.
BytesIO
(
b
'foo'
),
encoding
=
"rot13"
)
self
.
assertRaises
(
TypeError
,
t
.
write
,
'bar'
)
def
test_illegal_decoder
(
self
):
def
test_illegal_decoder
(
self
):
# Issue #17106
# Issue #17106
# Bypass the early encoding check added in issue 20404
# Bypass the early encoding check added in issue 20404
...
...
Misc/NEWS.d/next/Core and Builtins/2017-08-25-20-43-22.bpo-31271.YMduKF.rst
0 → 100644
Dosyayı görüntüle @
a5b4ea15
Fix an assertion failure in the write() method of `io.TextIOWrapper`, when
the encoder doesn't return a bytes object. Patch by Oren Milman.
Modules/_io/textio.c
Dosyayı görüntüle @
a5b4ea15
...
@@ -1387,6 +1387,13 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text)
...
@@ -1387,6 +1387,13 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text)
Py_DECREF
(
text
);
Py_DECREF
(
text
);
if
(
b
==
NULL
)
if
(
b
==
NULL
)
return
NULL
;
return
NULL
;
if
(
!
PyBytes_Check
(
b
))
{
PyErr_Format
(
PyExc_TypeError
,
"encoder should return a bytes object, not '%.200s'"
,
Py_TYPE
(
b
)
->
tp_name
);
Py_DECREF
(
b
);
return
NULL
;
}
if
(
self
->
pending_bytes
==
NULL
)
{
if
(
self
->
pending_bytes
==
NULL
)
{
self
->
pending_bytes
=
PyList_New
(
0
);
self
->
pending_bytes
=
PyList_New
(
0
);
...
...
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