Skip to content

Commit 8cc80f1

Browse files
committed
Merge 3.4
2 parents a3626bc + 579db16 commit 8cc80f1

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

Lib/test/multibytecodec_support.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@ def test_streamwriter(self):
270270

271271
self.assertEqual(ostream.getvalue(), self.tstring[0])
272272

273+
def test_streamwriter_reset_no_pending(self):
274+
# Issue #23247: Calling reset() on a fresh StreamWriter instance
275+
# (without pending data) must not crash
276+
stream = BytesIO()
277+
writer = self.writer(stream)
278+
writer.reset()
279+
273280

274281
class TestBase_Mapping(unittest.TestCase):
275282
pass_enctest = []

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ Core and Builtins
169169
Library
170170
-------
171171

172+
- Issue #23247: Fix a crash in the StreamWriter.reset() of CJK codecs.
173+
172174
- Issue #24270: Add math.isclose() and cmath.isclose() functions as per PEP 485.
173175
Contributed by Chris Barker and Tal Einat.
174176

Modules/cjkcodecs/multibytecodec.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,9 @@ _multibytecodec_MultibyteStreamWriter_reset_impl(MultibyteStreamWriterObject *se
16851685
{
16861686
PyObject *pwrt;
16871687

1688+
if (!self->pending)
1689+
Py_RETURN_NONE;
1690+
16881691
pwrt = multibytecodec_encode(self->codec, &self->state,
16891692
self->pending, NULL, self->errors,
16901693
MBENC_FLUSH | MBENC_RESET);

0 commit comments

Comments
 (0)