[Python-checkins] cpython: Issue #18408: Fix cjkcodecs decoders, add a new MBERR_EXCEPTION constant to
victor.stinner
python-checkins at python.org
Tue Jul 16 23:09:16 CEST 2013
http://hg.python.org/cpython/rev/f0efd7ea1627
changeset: 84670:f0efd7ea1627
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Jul 16 21:41:43 2013 +0200
summary:
Issue #18408: Fix cjkcodecs decoders, add a new MBERR_EXCEPTION constant to
notify exceptions raised by the _PyUnicodeWriter API
files:
Modules/cjkcodecs/cjkcodecs.h | 4 ++--
Modules/cjkcodecs/multibytecodec.c | 2 ++
Modules/cjkcodecs/multibytecodec.h | 1 +
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h
--- a/Modules/cjkcodecs/cjkcodecs.h
+++ b/Modules/cjkcodecs/cjkcodecs.h
@@ -130,7 +130,7 @@
#define OUTCHAR(c) \
do { \
if (_PyUnicodeWriter_WriteChar(writer, (c)) < 0) \
- return MBERR_TOOSMALL; \
+ return MBERR_EXCEPTION; \
} while (0)
#define OUTCHAR2(c1, c2) \
@@ -138,7 +138,7 @@
Py_UCS4 _c1 = (c1); \
Py_UCS4 _c2 = (c2); \
if (_PyUnicodeWriter_Prepare(writer, 2, Py_MAX(_c1, c2)) < 0) \
- return MBERR_TOOSMALL; \
+ return MBERR_EXCEPTION; \
PyUnicode_WRITE(writer->kind, writer->data, writer->pos, _c1); \
PyUnicode_WRITE(writer->kind, writer->data, writer->pos + 1, _c2); \
writer->pos += 2; \
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -384,6 +384,8 @@
PyErr_SetString(PyExc_RuntimeError,
"internal codec error");
return -1;
+ case MBERR_EXCEPTION:
+ return -1;
default:
PyErr_SetString(PyExc_RuntimeError,
"unknown runtime error");
diff --git a/Modules/cjkcodecs/multibytecodec.h b/Modules/cjkcodecs/multibytecodec.h
--- a/Modules/cjkcodecs/multibytecodec.h
+++ b/Modules/cjkcodecs/multibytecodec.h
@@ -112,6 +112,7 @@
#define MBERR_TOOSMALL (-1) /* insufficient output buffer space */
#define MBERR_TOOFEW (-2) /* incomplete input buffer */
#define MBERR_INTERNAL (-3) /* internal runtime error */
+#define MBERR_EXCEPTION (-4) /* an exception has been raised */
#define ERROR_STRICT (PyObject *)(1)
#define ERROR_IGNORE (PyObject *)(2)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list