comparison Modules/arraymodule.c @ 80826:757cc49ced54 3.3

Code style fixup: No need for double ((parenthesis)) and use {} on an if else.
author Gregory P. Smith <greg@krypto.org>
date Mon, 10 Dec 2012 20:22:31 -0800
parents 152d85b2da3a 88dcccb46298
children 3ca72d4e9762 bc322469a7a8
comparison
equal deleted inserted replaced
80823:11236dacc76f 80826:757cc49ced54
1520 char typecode; 1520 char typecode;
1521 1521
1522 if (!PyArg_ParseTuple(args, "u#:fromunicode", &ustr, &n)) 1522 if (!PyArg_ParseTuple(args, "u#:fromunicode", &ustr, &n))
1523 return NULL; 1523 return NULL;
1524 typecode = self->ob_descr->typecode; 1524 typecode = self->ob_descr->typecode;
1525 if ((typecode != 'u')) { 1525 if (typecode != 'u') {
1526 PyErr_SetString(PyExc_ValueError, 1526 PyErr_SetString(PyExc_ValueError,
1527 "fromunicode() may only be called on " 1527 "fromunicode() may only be called on "
1528 "unicode type arrays"); 1528 "unicode type arrays");
1529 return NULL; 1529 return NULL;
1530 } 1530 }
1552 static PyObject * 1552 static PyObject *
1553 array_tounicode(arrayobject *self, PyObject *unused) 1553 array_tounicode(arrayobject *self, PyObject *unused)
1554 { 1554 {
1555 char typecode; 1555 char typecode;
1556 typecode = self->ob_descr->typecode; 1556 typecode = self->ob_descr->typecode;
1557 if ((typecode != 'u')) { 1557 if (typecode != 'u') {
1558 PyErr_SetString(PyExc_ValueError, 1558 PyErr_SetString(PyExc_ValueError,
1559 "tounicode() may only be called on unicode type arrays"); 1559 "tounicode() may only be called on unicode type arrays");
1560 return NULL; 1560 return NULL;
1561 } 1561 }
1562 return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, Py_SIZE(self)); 1562 return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, Py_SIZE(self));
2175 len = Py_SIZE(a); 2175 len = Py_SIZE(a);
2176 typecode = a->ob_descr->typecode; 2176 typecode = a->ob_descr->typecode;
2177 if (len == 0) { 2177 if (len == 0) {
2178 return PyUnicode_FromFormat("array('%c')", (int)typecode); 2178 return PyUnicode_FromFormat("array('%c')", (int)typecode);
2179 } 2179 }
2180 if (typecode == 'u') 2180 if (typecode == 'u') {
2181 v = array_tounicode(a, NULL); 2181 v = array_tounicode(a, NULL);
2182 else 2182 } else {
2183 v = array_tolist(a, NULL); 2183 v = array_tolist(a, NULL);
2184 }
2184 2185
2185 s = PyUnicode_FromFormat("array('%c', %R)", (int)typecode, v); 2186 s = PyUnicode_FromFormat("array('%c', %R)", (int)typecode, v);
2186 Py_DECREF(v); 2187 Py_DECREF(v);
2187 return s; 2188 return s;
2188 } 2189 }