[Python-checkins] cpython: always explicitly check for -1 from PyUnicode_READY
benjamin.peterson
python-checkins at python.org
Sat Jan 14 19:37:37 CET 2012
http://hg.python.org/cpython/rev/c39bada2a60f
changeset: 74406:c39bada2a60f
user: Benjamin Peterson <benjamin at python.org>
date: Sat Jan 14 13:34:47 2012 -0500
summary:
always explicitly check for -1 from PyUnicode_READY
files:
Objects/unicodeobject.c | 70 ++++++++++++++--------------
1 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -491,7 +491,7 @@
unicode_result_unchanged(PyObject *unicode)
{
if (PyUnicode_CheckExact(unicode)) {
- if (PyUnicode_READY(unicode) < 0)
+ if (PyUnicode_READY(unicode) == -1)
return NULL;
Py_INCREF(unicode);
return unicode;
@@ -764,7 +764,7 @@
if (_PyUnicode_KIND(unicode) != PyUnicode_WCHAR_KIND) {
PyObject *copy;
- if (PyUnicode_READY(unicode) < 0)
+ if (PyUnicode_READY(unicode) == -1)
return NULL;
copy = PyUnicode_New(length, PyUnicode_MAX_CHAR_VALUE(unicode));
@@ -1263,9 +1263,9 @@
return -1;
}
- if (PyUnicode_READY(from))
+ if (PyUnicode_READY(from) == -1)
return -1;
- if (PyUnicode_READY(to))
+ if (PyUnicode_READY(to) == -1)
return -1;
how_many = Py_MIN(PyUnicode_GET_LENGTH(from), how_many);
@@ -1959,7 +1959,7 @@
PyErr_BadInternalCall();
return NULL;
}
- if (PyUnicode_READY(unicode))
+ if (PyUnicode_READY(unicode) == -1)
return NULL;
length = PyUnicode_GET_LENGTH(unicode);
@@ -1985,7 +1985,7 @@
void *result;
unsigned int skind;
- if (PyUnicode_READY(s))
+ if (PyUnicode_READY(s) == -1)
return NULL;
len = PyUnicode_GET_LENGTH(s);
@@ -2471,7 +2471,7 @@
str_obj = PyUnicode_DecodeUTF8Stateful(str, strlen(str), "replace", NULL);
if (!str_obj)
goto fail;
- if (PyUnicode_READY(str_obj)) {
+ if (PyUnicode_READY(str_obj) == -1) {
Py_DECREF(str_obj);
goto fail;
}
@@ -2813,7 +2813,7 @@
/* XXX Perhaps we should make this API an alias of
PyObject_Str() instead ?! */
if (PyUnicode_CheckExact(obj)) {
- if (PyUnicode_READY(obj))
+ if (PyUnicode_READY(obj) == -1)
return NULL;
Py_INCREF(obj);
return obj;
@@ -3611,7 +3611,7 @@
return 1;
}
if (PyUnicode_Check(arg)) {
- if (PyUnicode_READY(arg))
+ if (PyUnicode_READY(arg) == -1)
return 0;
output = arg;
Py_INCREF(output);
@@ -3631,7 +3631,7 @@
return 0;
}
}
- if (PyUnicode_READY(output) < 0) {
+ if (PyUnicode_READY(output) == -1) {
Py_DECREF(output);
return 0;
}
@@ -3957,7 +3957,7 @@
}
if (!PyArg_ParseTuple(restuple, argparse, &PyUnicode_Type, &repunicode, &newpos))
goto onError;
- if (PyUnicode_READY(repunicode) < 0)
+ if (PyUnicode_READY(repunicode) == -1)
goto onError;
/* Copy back the bytes variables, which might have been modified by the
@@ -4330,7 +4330,7 @@
char * out;
char * start;
- if (PyUnicode_READY(str) < 0)
+ if (PyUnicode_READY(str) == -1)
return NULL;
kind = PyUnicode_KIND(str);
data = PyUnicode_DATA(str);
@@ -5224,7 +5224,7 @@
PyErr_BadArgument();
return NULL;
}
- if (PyUnicode_READY(str) < 0)
+ if (PyUnicode_READY(str) == -1)
return NULL;
kind = PyUnicode_KIND(str);
data = PyUnicode_DATA(str);
@@ -5590,7 +5590,7 @@
PyErr_BadArgument();
return NULL;
}
- if (PyUnicode_READY(str) < 0)
+ if (PyUnicode_READY(str) == -1)
return NULL;
kind = PyUnicode_KIND(str);
data = PyUnicode_DATA(str);
@@ -6021,7 +6021,7 @@
PyErr_BadArgument();
return NULL;
}
- if (PyUnicode_READY(unicode) < 0)
+ if (PyUnicode_READY(unicode) == -1)
return NULL;
len = PyUnicode_GET_LENGTH(unicode);
kind = PyUnicode_KIND(unicode);
@@ -6254,7 +6254,7 @@
PyErr_BadArgument();
return NULL;
}
- if (PyUnicode_READY(unicode) < 0)
+ if (PyUnicode_READY(unicode) == -1)
return NULL;
kind = PyUnicode_KIND(unicode);
data = PyUnicode_DATA(unicode);
@@ -6500,7 +6500,7 @@
return NULL;
}
- if (PyUnicode_READY(unicode) < 0)
+ if (PyUnicode_READY(unicode) == -1)
return NULL;
len = PyUnicode_GET_LENGTH(unicode);
@@ -6563,7 +6563,7 @@
* -1=not initialized, 0=unknown, 1=strict, 2=replace, 3=ignore, 4=xmlcharrefreplace */
int known_errorHandler = -1;
- if (PyUnicode_READY(unicode) < 0)
+ if (PyUnicode_READY(unicode) == -1)
return NULL;
size = PyUnicode_GET_LENGTH(unicode);
kind = PyUnicode_KIND(unicode);
@@ -6662,7 +6662,7 @@
encoding, reason, unicode, &exc,
collstart, collend, &newpos);
if (repunicode == NULL || (PyUnicode_Check(repunicode) &&
- PyUnicode_READY(repunicode) < 0))
+ PyUnicode_READY(repunicode) == -1))
goto onError;
if (PyBytes_Check(repunicode)) {
/* Directly copy bytes result to output. */
@@ -7525,7 +7525,7 @@
enum PyUnicode_Kind kind;
void *data;
- if (PyUnicode_READY(rep) < 0) {
+ if (PyUnicode_READY(rep) == -1) {
Py_DECREF(rep);
goto error;
}
@@ -7583,7 +7583,7 @@
Py_ssize_t offset;
int chunk_len, ret, done;
- if (PyUnicode_READY(unicode) < 0)
+ if (PyUnicode_READY(unicode) == -1)
return NULL;
len = PyUnicode_GET_LENGTH(unicode);
@@ -7702,7 +7702,7 @@
void *data;
Py_UCS4 x;
- if (PyUnicode_READY(mapping) < 0)
+ if (PyUnicode_READY(mapping) == -1)
return NULL;
maplen = PyUnicode_GET_LENGTH(mapping);
@@ -7787,7 +7787,7 @@
else if (PyUnicode_Check(x)) {
Py_ssize_t targetsize;
- if (PyUnicode_READY(x) < 0)
+ if (PyUnicode_READY(x) == -1)
goto onError;
targetsize = PyUnicode_GET_LENGTH(x);
@@ -8203,7 +8203,7 @@
Py_UCS4 ch;
int val;
- if (PyUnicode_READY(unicode) < 0)
+ if (PyUnicode_READY(unicode) == -1)
return -1;
size = PyUnicode_GET_LENGTH(unicode);
/* find all unencodable characters */
@@ -8306,7 +8306,7 @@
break;
}
/* generate replacement */
- if (PyUnicode_READY(repunicode) < 0) {
+ if (PyUnicode_READY(repunicode) == -1) {
Py_DECREF(repunicode);
return -1;
}
@@ -8351,7 +8351,7 @@
* 3=ignore, 4=xmlcharrefreplace */
int known_errorHandler = -1;
- if (PyUnicode_READY(unicode) < 0)
+ if (PyUnicode_READY(unicode) == -1)
return NULL;
size = PyUnicode_GET_LENGTH(unicode);
@@ -8953,7 +8953,7 @@
if (unicode == NULL)
return -1;
- if (PyUnicode_READY(unicode) < 0) {
+ if (PyUnicode_READY(unicode) == -1) {
Py_DECREF(unicode);
return -1;
}
@@ -10576,7 +10576,7 @@
if (!PyArg_ParseTuple(args, "n|O&:center", &width, convert_uc, &fillchar))
return NULL;
- if (PyUnicode_READY(self) < 0)
+ if (PyUnicode_READY(self) == -1)
return NULL;
if (PyUnicode_GET_LENGTH(self) >= width)
@@ -10870,9 +10870,9 @@
goto error;
}
- if (PyUnicode_READY(left))
+ if (PyUnicode_READY(left) == -1)
goto error;
- if (PyUnicode_READY(right))
+ if (PyUnicode_READY(right) == -1)
goto error;
/* Shortcuts */
@@ -11735,7 +11735,7 @@
if (!PyArg_ParseTuple(args, "n|O&:ljust", &width, convert_uc, &fillchar))
return NULL;
- if (PyUnicode_READY(self) < 0)
+ if (PyUnicode_READY(self) == -1)
return NULL;
if (PyUnicode_GET_LENGTH(self) >= width)
@@ -11965,7 +11965,7 @@
if (len == 1)
return unicode_result_unchanged(str);
- if (PyUnicode_READY(str) < 0)
+ if (PyUnicode_READY(str) == -1)
return NULL;
if (PyUnicode_GET_LENGTH(str) > PY_SSIZE_T_MAX / len) {
@@ -12329,7 +12329,7 @@
if (!PyArg_ParseTuple(args, "n|O&:rjust", &width, convert_uc, &fillchar))
return NULL;
- if (PyUnicode_READY(self) < 0)
+ if (PyUnicode_READY(self) == -1)
return NULL;
if (PyUnicode_GET_LENGTH(self) >= width)
@@ -12817,7 +12817,7 @@
if (!PyArg_ParseTuple(args, "n:zfill", &width))
return NULL;
- if (PyUnicode_READY(self) < 0)
+ if (PyUnicode_READY(self) == -1)
return NULL;
if (PyUnicode_GET_LENGTH(self) >= width)
@@ -13836,7 +13836,7 @@
if (unicode == NULL)
return NULL;
assert(_PyUnicode_CHECK(unicode));
- if (PyUnicode_READY(unicode)) {
+ if (PyUnicode_READY(unicode) == -1) {
Py_DECREF(unicode);
return NULL;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list