merge (including cwitty's change to get_exception_utility_code)
authorRobert Bradshaw <robertwb@math.washington.edu>
Sat, 20 Oct 2007 19:18:21 +0000 (12:18 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sat, 20 Oct 2007 19:18:21 +0000 (12:18 -0700)
1  2 
Cython/Compiler/ExprNodes.py
Cython/Compiler/Nodes.py

Simple merge
index 8c20c1c26e3998aa21c7b6ff8213b81eacaa583b,eba442bd4943210ecaaffc22b711ccd8cad4c8b7..d4df57c764c21792ed5f93bd60fbfc607d605a9f
@@@ -3331,40 -3424,32 +3424,38 @@@ static int __Pyx_InitStrings(__Pyx_Stri
  
  #------------------------------------------------------------------------------------
  
c_api_import_code = [
get_exception_utility_code = [
  """
- static int __Pyx_InitCApi(PyObject *module); /*proto*/
- static int __Pyx_ImportModuleCApi(__Pyx_CApiTabEntry *t); /*proto*/
+ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
  ""","""
- static int __Pyx_ImportModuleCApi(__Pyx_CApiTabEntry *t) {
-     __Pyx_CApiTabEntry *api_t;
-     while (t->s) {
-         if (*t->s == '\\0')
-             continue; /* shortcut for erased string entries */
-         api_t = %(API_TAB)s;
-         while ((api_t->s) && (strcmp(api_t->s, t->s) < 0))
-             ++api_t;
-         if ((!api_t->p) || (strcmp(api_t->s, t->s) != 0)) {
-             PyErr_Format(PyExc_ValueError,
-                          "Unknown function name in C API: %%s", t->s);
-             return -1;
-         }
-         *t->p = api_t->p;
-         ++t;
-     }
+ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
++    PyObject *tmp_type, *tmp_value, *tmp_tb;
+     PyThreadState *tstate = PyThreadState_Get();
+     PyErr_Fetch(type, value, tb);
+     PyErr_NormalizeException(type, value, tb);
+     if (PyErr_Occurred())
+         goto bad;
+     Py_INCREF(*type);
+     Py_INCREF(*value);
+     Py_INCREF(*tb);
 -    Py_XDECREF(tstate->exc_type);
 -    Py_XDECREF(tstate->exc_value);
 -    Py_XDECREF(tstate->exc_traceback);
++    tmp_type = tstate->exc_type;
++    tmp_value = tstate->exc_value;
++    tmp_tb = tstate->exc_traceback;
+     tstate->exc_type = *type;
+     tstate->exc_value = *value;
+     tstate->exc_traceback = *tb;
++    /* Make sure tstate is in a consistent state when we XDECREF
++    these objects (XDECREF may run arbitrary code). */
++    Py_XDECREF(tmp_type);
++    Py_XDECREF(tmp_value);
++    Py_XDECREF(tmp_tb);
      return 0;
+ bad:
+     Py_XDECREF(*type);
+     Py_XDECREF(*value);
+     Py_XDECREF(*tb);
+     return -1;
  }
+ """]
  
- static int __Pyx_InitCApi(PyObject *module) {
-     int result;
-     PyObject* cobj = PyCObject_FromVoidPtr(&__Pyx_ImportModuleCApi, NULL);
-     if (!cobj)
-         return -1;
-     result = PyObject_SetAttrString(module, "_import_c_api", cobj);
-     Py_DECREF(cobj);
-     return result;
- }
- """ % {'API_TAB' : Naming.c_api_tab_cname}
- ]
  #------------------------------------------------------------------------------------