summaryrefslogtreecommitdiffstats
path: root/Objects/stringobject.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-05-09 00:24:55 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-05-09 00:24:55 (GMT)
commitcf5ad5d6f6e6db029b6e7701b8d964ad21406641 (patch)
treeb2e796238db94e61f09bf3fb2bc379838db6244e /Objects/stringobject.c
parent5b4d47756871a11621dc4d96e58a9180479704f3 (diff)
downloadcpython-cf5ad5d6f6e6db029b6e7701b8d964ad21406641.zip
cpython-cf5ad5d6f6e6db029b6e7701b8d964ad21406641.tar.gz
cpython-cf5ad5d6f6e6db029b6e7701b8d964ad21406641.tar.bz2
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>.
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r--Objects/stringobject.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index afaa054..5bdbce9 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -553,7 +553,6 @@ string_contains(PyObject *a, PyObject *el)
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 @@ string_item(PyStringObject *a, register int i)
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;
}