summaryrefslogtreecommitdiffstats
path: root/Modules/arraymodule.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2000-11-10 19:04:19 (GMT)
committerTim Peters <tim.peters@gmail.com>2000-11-10 19:04:19 (GMT)
commit7c1cb461263149129984fcae5530c5fbf9105b74 (patch)
treeea76145d41586795a742e20df2b5a34dc5650068 /Modules/arraymodule.c
parente5cd584b9fa9592c729c0a1cdf1f84829882b6f9 (diff)
downloadcpython-7c1cb461263149129984fcae5530c5fbf9105b74.zip
cpython-7c1cb461263149129984fcae5530c5fbf9105b74.tar.gz
cpython-7c1cb461263149129984fcae5530c5fbf9105b74.tar.bz2
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.
Diffstat (limited to 'Modules/arraymodule.c')
-rw-r--r--Modules/arraymodule.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index ad7bcc2..8da9139 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -1191,7 +1191,6 @@ array_print(arrayobject *a, FILE *fp, int flags)
{
int ok = 0;
int i, len;
- PyObject *t_empty = PyTuple_New(0);
PyObject *v;
len = a->ob_size;
if (len == 0) {
@@ -1199,9 +1198,10 @@ array_print(arrayobject *a, FILE *fp, int flags)
return ok;
}
if (a->ob_descr->typecode == 'c') {
+ PyObject *t_empty = PyTuple_New(0);
fprintf(fp, "array('c', ");
v = array_tostring(a, t_empty);
- Py_DECREF(t_empty);;
+ Py_DECREF(t_empty);
ok = PyObject_Print(v, fp, 0);
Py_XDECREF(v);
fprintf(fp, ")");
@@ -1231,9 +1231,11 @@ array_repr(arrayobject *a)
return PyString_FromString(buf);
}
if (a->ob_descr->typecode == 'c') {
+ PyObject *t_empty = PyTuple_New(0);
sprintf(buf, "array('c', ");
s = PyString_FromString(buf);
- v = array_tostring(a, (PyObject *)NULL);
+ v = array_tostring(a, t_empty);
+ Py_DECREF(t_empty);
t = PyObject_Repr(v);
Py_XDECREF(v);
PyString_ConcatAndDel(&s, t);