[Numpy-svn] r8697 - branches/1.5.x/numpy/core/src/multiarray

numpy-svn at scipy.org numpy-svn at scipy.org
Sun Sep 5 11:29:22 EDT 2010


Author: ptvirtan
Date: 2010-09-05 10:29:22 -0500 (Sun, 05 Sep 2010)
New Revision: 8697

Modified:
   branches/1.5.x/numpy/core/src/multiarray/buffer.c
Log:
BUG: core/buffer: ensure that array_dealloc runs correctly even when PyErr flag is set (fixes #1605)

Modified: branches/1.5.x/numpy/core/src/multiarray/buffer.c
===================================================================
--- branches/1.5.x/numpy/core/src/multiarray/buffer.c	2010-09-05 15:23:39 UTC (rev 8696)
+++ branches/1.5.x/numpy/core/src/multiarray/buffer.c	2010-09-05 15:29:22 UTC (rev 8697)
@@ -671,7 +671,23 @@
 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




More information about the Numpy-svn mailing list