Mercurial > cpython-lru_cache-weakref
diff Objects/stringobject.c @ 17711:350be19ca6a5 legacy-trunk
My change to string_item() left an extra reference to each 1-character
interned string created by "string"[i]. Since they're immortal anyway,
this was hard to notice, but it was still wrong <wink>.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Wed, 09 May 2001 00:24:55 +0000 |
| parents | 6199e5bd370b |
| children | 2a7cfc172a68 |
line wrap: on
line diff
--- a/Objects/stringobject.c Tue May 08 22:33:50 2001 +0000 +++ b/Objects/stringobject.c Wed May 09 00:24:55 2001 +0000 @@ -553,7 +553,6 @@ static PyObject * string_item(PyStringObject *a, register int i) { - int c; PyObject *v; char *pchar; if (i < 0 || i >= a->ob_size) { @@ -561,11 +560,11 @@ return NULL; } pchar = a->ob_sval + i; - c = *pchar & UCHAR_MAX; - v = (PyObject *) characters[c]; + v = (PyObject *)characters[*pchar & UCHAR_MAX]; if (v == NULL) v = PyString_FromStringAndSize(pchar, 1); - Py_XINCREF(v); + else + Py_INCREF(v); return v; }
