Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 32900:ac73f6662e11 legacy-trunk
Fix for the unfortunate fact that PyDict_GetItem and PyObject_GetItem
have differing refcount semantics. If anyone sees a prettier way to
acheive the same ends, then please go for it.
I think this is the first time I've ever used Py_XINCREF.
| author | Michael W. Hudson <mwh@python.net> |
|---|---|
| date | Mon, 02 Aug 2004 14:50:43 +0000 |
| parents | b8c2aa2be19a |
| children | fb6ffd290cfb |
line wrap: on
line diff
--- a/Python/ceval.c Mon Aug 02 13:48:18 2004 +0000 +++ b/Python/ceval.c Mon Aug 02 14:50:43 2004 +0000 @@ -1742,8 +1742,10 @@ PyObject_REPR(w)); break; } - if (PyDict_CheckExact(v)) + if (PyDict_CheckExact(v)) { x = PyDict_GetItem(v, w); + Py_XINCREF(x); + } else { x = PyObject_GetItem(v, w); if (x == NULL && PyErr_Occurred()) { @@ -1763,8 +1765,8 @@ break; } } + Py_INCREF(x); } - Py_INCREF(x); PUSH(x); continue;
