[Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.144,2.145
Jeremy Hylton
jhylton@users.sourceforge.net
Thu, 06 Dec 2001 07:18:50 -0800
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv20379
Modified Files:
stringobject.c
Log Message:
Little stuff.
Add a missing DECREF in an obscure corner. If the str() or repr() of
an object passed to a string interpolation -- e.g. "%s" % obj --
returns a non-string, the returned object was leaked.
Repair an indentation glitch.
Replace a bunch of PyString_AsString() calls (and their ilk) with
macros.
Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.144
retrieving revision 2.145
diff -C2 -d -r2.144 -r2.145
*** stringobject.c 2001/12/03 08:24:52 2.144
--- stringobject.c 2001/12/06 15:18:48 2.145
***************
*** 3147,3152 ****
}
orig_args = args;
! fmt = PyString_AsString(format);
! fmtcnt = PyString_Size(format);
reslen = rescnt = fmtcnt + 100;
result = PyString_FromStringAndSize((char *)NULL, reslen);
--- 3147,3152 ----
}
orig_args = args;
! fmt = PyString_AS_STRING(format);
! fmtcnt = PyString_GET_SIZE(format);
reslen = rescnt = fmtcnt + 100;
result = PyString_FromStringAndSize((char *)NULL, reslen);
***************
*** 3155,3159 ****
res = PyString_AsString(result);
if (PyTuple_Check(args)) {
! arglen = PyTuple_Size(args);
argidx = 0;
}
--- 3155,3159 ----
res = PyString_AsString(result);
if (PyTuple_Check(args)) {
! arglen = PyTuple_GET_SIZE(args);
argidx = 0;
}
***************
*** 3171,3175 ****
if (_PyString_Resize(&result, reslen) < 0)
return NULL;
! res = PyString_AsString(result)
+ reslen - rescnt;
--rescnt;
--- 3171,3175 ----
if (_PyString_Resize(&result, reslen) < 0)
return NULL;
! res = PyString_AS_STRING(result)
+ reslen - rescnt;
--rescnt;
***************
*** 3352,3356 ****
#endif
if (c == 's')
! temp = PyObject_Str(v);
else
temp = PyObject_Repr(v);
--- 3352,3356 ----
#endif
if (c == 's')
! temp = PyObject_Str(v);
else
temp = PyObject_Repr(v);
***************
*** 3360,3367 ****
PyErr_SetString(PyExc_TypeError,
"%s argument has non-string str()");
goto error;
}
! pbuf = PyString_AsString(temp);
! len = PyString_Size(temp);
if (prec >= 0 && len > prec)
len = prec;
--- 3360,3368 ----
PyErr_SetString(PyExc_TypeError,
"%s argument has non-string str()");
+ Py_DECREF(temp);
goto error;
}
! pbuf = PyString_AS_STRING(temp);
! len = PyString_GET_SIZE(temp);
if (prec >= 0 && len > prec)
len = prec;
***************
*** 3442,3446 ****
if (_PyString_Resize(&result, reslen) < 0)
return NULL;
! res = PyString_AsString(result)
+ reslen - rescnt;
}
--- 3443,3447 ----
if (_PyString_Resize(&result, reslen) < 0)
return NULL;
! res = PyString_AS_STRING(result)
+ reslen - rescnt;
}