Commit 7c1cb461 authored by Tim Peters's avatar Tim Peters

Fix for SF bug 117402, crashes on str(array) and repr(array). This was an

unfortunate consequence of somebody switching from PyArg_Parse to
PyArg_ParseTuple but without changing the argument from a NULL to a tuple.
parent e5cd584b
...@@ -1191,7 +1191,6 @@ array_print(arrayobject *a, FILE *fp, int flags) ...@@ -1191,7 +1191,6 @@ array_print(arrayobject *a, FILE *fp, int flags)
{ {
int ok = 0; int ok = 0;
int i, len; int i, len;
PyObject *t_empty = PyTuple_New(0);
PyObject *v; PyObject *v;
len = a->ob_size; len = a->ob_size;
if (len == 0) { if (len == 0) {
...@@ -1199,9 +1198,10 @@ array_print(arrayobject *a, FILE *fp, int flags) ...@@ -1199,9 +1198,10 @@ array_print(arrayobject *a, FILE *fp, int flags)
return ok; return ok;
} }
if (a->ob_descr->typecode == 'c') { if (a->ob_descr->typecode == 'c') {
PyObject *t_empty = PyTuple_New(0);
fprintf(fp, "array('c', "); fprintf(fp, "array('c', ");
v = array_tostring(a, t_empty); v = array_tostring(a, t_empty);
Py_DECREF(t_empty);; Py_DECREF(t_empty);
ok = PyObject_Print(v, fp, 0); ok = PyObject_Print(v, fp, 0);
Py_XDECREF(v); Py_XDECREF(v);
fprintf(fp, ")"); fprintf(fp, ")");
...@@ -1231,9 +1231,11 @@ array_repr(arrayobject *a) ...@@ -1231,9 +1231,11 @@ array_repr(arrayobject *a)
return PyString_FromString(buf); return PyString_FromString(buf);
} }
if (a->ob_descr->typecode == 'c') { if (a->ob_descr->typecode == 'c') {
PyObject *t_empty = PyTuple_New(0);
sprintf(buf, "array('c', "); sprintf(buf, "array('c', ");
s = PyString_FromString(buf); s = PyString_FromString(buf);
v = array_tostring(a, (PyObject *)NULL); v = array_tostring(a, t_empty);
Py_DECREF(t_empty);
t = PyObject_Repr(v); t = PyObject_Repr(v);
Py_XDECREF(v); Py_XDECREF(v);
PyString_ConcatAndDel(&s, t); PyString_ConcatAndDel(&s, t);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment