diff options
author | Pauli Virtanen <pav@iki.fi> | 2010-09-05 15:23:39 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2010-09-05 15:23:39 +0000 |
commit | bf8f5f49f5554c115da5d3da0802a20786209cb8 (patch) | |
tree | 02741074ecfc5671ff9aba30f9452f8738d62dbd /numpy | |
parent | 59a95e87f7225adcbad28bf40b0e1f4f6071f59f (diff) | |
download | numpy-bf8f5f49f5554c115da5d3da0802a20786209cb8.tar.gz |
BUG: core/buffer: ensure that array_dealloc runs correctly even when PyErr flag is set (fixes #1605)
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/multiarray/buffer.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/buffer.c b/numpy/core/src/multiarray/buffer.c index 9fedece17..08e2687a0 100644 --- a/numpy/core/src/multiarray/buffer.c +++ b/numpy/core/src/multiarray/buffer.c @@ -671,7 +671,23 @@ fail: NPY_NO_EXPORT void _array_dealloc_buffer_info(PyArrayObject *self) { + int reset_error_state = 0; + PyObject *ptype, *pvalue, *ptraceback; + + /* This function may be called when processing an exception -- + * we need to stash the error state to avoid confusing PyDict + */ + + if (PyErr_Occurred()) { + reset_error_state = 1; + PyErr_Fetch(&ptype, &pvalue, &ptraceback); + } + _buffer_clear_info((PyObject*)self); + + if (reset_error_state) { + PyErr_Restore(ptype, pvalue, ptraceback); + } } #else |