[Python-checkins] cpython (merge 3.4 -> 3.5): Merge 3.4
victor.stinner
python-checkins at python.org
Thu Jul 16 22:22:55 CEST 2015
https://hg.python.org/cpython/rev/6cc38d283577
changeset: 96921:6cc38d283577
branch: 3.5
parent: 96917:5c3812412b6f
parent: 96920:35a6fe0e2b27
user: Victor Stinner <victor.stinner at gmail.com>
date: Thu Jul 16 22:20:19 2015 +0200
summary:
Merge 3.4
files:
Lib/test/multibytecodec_support.py | 7 +++++++
Misc/NEWS | 2 ++
Modules/cjkcodecs/multibytecodec.c | 3 +++
3 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/Lib/test/multibytecodec_support.py b/Lib/test/multibytecodec_support.py
--- a/Lib/test/multibytecodec_support.py
+++ b/Lib/test/multibytecodec_support.py
@@ -270,6 +270,13 @@
self.assertEqual(ostream.getvalue(), self.tstring[0])
+ def test_streamwriter_reset_no_pending(self):
+ # Issue #23247: Calling reset() on a fresh StreamWriter instance
+ # (without pending data) must not crash
+ stream = BytesIO()
+ writer = self.writer(stream)
+ writer.reset()
+
class TestBase_Mapping(unittest.TestCase):
pass_enctest = []
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -169,6 +169,8 @@
Library
-------
+- Issue #23247: Fix a crash in the StreamWriter.reset() of CJK codecs.
+
- Issue #24270: Add math.isclose() and cmath.isclose() functions as per PEP 485.
Contributed by Chris Barker and Tal Einat.
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -1685,6 +1685,9 @@
{
PyObject *pwrt;
+ if (!self->pending)
+ Py_RETURN_NONE;
+
pwrt = multibytecodec_encode(self->codec, &self->state,
self->pending, NULL, self->errors,
MBENC_FLUSH | MBENC_RESET);
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list