[Python-checkins] cpython (merge default -> default): Merge heads
petri.lehtinen
python-checkins at python.org
Fri Nov 4 21:41:50 CET 2011
http://hg.python.org/cpython/rev/cade039a7be4
changeset: 73362:cade039a7be4
parent: 73361:d90d88380aca
parent: 73359:e3b6458056c7
user: Petri Lehtinen <petri at digip.org>
date: Fri Nov 04 22:36:54 2011 +0200
summary:
Merge heads
files:
Python/codecs.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/Python/codecs.c b/Python/codecs.c
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -573,7 +573,7 @@
if (PyObject_IsInstance(exc, PyExc_UnicodeEncodeError)) {
PyObject *restuple;
PyObject *object;
- Py_ssize_t i, o;
+ Py_ssize_t i;
Py_ssize_t start;
Py_ssize_t end;
PyObject *res;
@@ -612,7 +612,7 @@
}
outp = PyUnicode_1BYTE_DATA(res);
/* generate replacement */
- for (i = start, o = 0; i < end; ++i) {
+ for (i = start; i < end; ++i) {
int digits;
int base;
ch = PyUnicode_READ_CHAR(object, i);
@@ -778,7 +778,7 @@
}
else if (PyObject_IsInstance(exc, PyExc_UnicodeDecodeError)) {
unsigned char *p;
- Py_UNICODE ch = 0;
+ Py_UCS4 ch = 0;
if (PyUnicodeDecodeError_GetStart(exc, &start))
return NULL;
if (!(object = PyUnicodeDecodeError_GetObject(exc)))
@@ -804,7 +804,10 @@
PyErr_SetObject(PyExceptionInstance_Class(exc), exc);
return NULL;
}
- return Py_BuildValue("(u#n)", &ch, 1, start+3);
+ res = PyUnicode_FromOrdinal(ch);
+ if (res == NULL)
+ return NULL;
+ return Py_BuildValue("(Nn)", res, start+3);
}
else {
wrong_exception_type(exc);
@@ -853,8 +856,9 @@
return restuple;
}
else if (PyObject_IsInstance(exc, PyExc_UnicodeDecodeError)) {
+ PyObject *str;
unsigned char *p;
- Py_UNICODE ch[4]; /* decode up to 4 bad bytes. */
+ Py_UCS2 ch[4]; /* decode up to 4 bad bytes. */
int consumed = 0;
if (PyUnicodeDecodeError_GetStart(exc, &start))
return NULL;
@@ -879,7 +883,10 @@
PyErr_SetObject(PyExceptionInstance_Class(exc), exc);
return NULL;
}
- return Py_BuildValue("(u#n)", ch, consumed, start+consumed);
+ str = PyUnicode_FromKindAndData(PyUnicode_2BYTE_KIND, ch, consumed);
+ if (str == NULL)
+ return NULL;
+ return Py_BuildValue("(Nn)", str, start+consumed);
}
else {
wrong_exception_type(exc);
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list