diff -r 6ef65516fd7a -r fac0421cb7b2 Modules/_pickle.c --- a/Modules/_pickle.c Tue Aug 09 16:07:01 2011 -0500 +++ b/Modules/_pickle.c Wed Aug 10 16:45:46 2011 +0100 @@ -4804,11 +4804,12 @@ static int load_put(UnpicklerObject *self) { - PyObject *key, *value; + PyObject *value; Py_ssize_t idx; Py_ssize_t len; char *s; - + char *ptr; + if ((len = _Unpickler_Readline(self, &s)) < 0) return -1; if (len < 2) @@ -4817,11 +4818,12 @@ return stack_underflow(); value = self->stack->data[Py_SIZE(self->stack) - 1]; - key = PyLong_FromString(s, NULL, 10); - if (key == NULL) + idx = PyOS_strtol(s, &ptr, 10); + if (ptr == s) { /* no characters consumed */ + PyErr_Format(PyExc_ValueError, + "invalid literal for int() with base 10: %s", s); return -1; - idx = PyLong_AsSsize_t(key); - Py_DECREF(key); + } if (idx == -1 && PyErr_Occurred()) return -1;