diff options
| author | Michael W. Hudson <mwh@python.net> | 2004-08-02 14:50:43 +0000 |
|---|---|---|
| committer | Michael W. Hudson <mwh@python.net> | 2004-08-02 14:50:43 +0000 |
| commit | 8c277c715c8a10d54537cfb7a29a6e852254cb64 (patch) | |
| tree | 4a3d70864a88360136daf8593138ac5fb03e0a5e /Python | |
| parent | 0ab63085856dc754e8e37e8c3ce893dfa95bd4f8 (diff) | |
| download | cpython-8c277c715c8a10d54537cfb7a29a6e852254cb64.tar.gz | |
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.
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/ceval.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 3a462afbed..6c457e125c 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1742,8 +1742,10 @@ PyEval_EvalFrame(PyFrameObject *f) 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 @@ PyEval_EvalFrame(PyFrameObject *f) break; } } + Py_INCREF(x); } - Py_INCREF(x); PUSH(x); continue; |
