[pypy-svn] r34561 - pypy/dist/pypy/translator/c/src

arigo at codespeak.net arigo at codespeak.net
Mon Nov 13 14:19:55 CET 2006


Author: arigo
Date: Mon Nov 13 14:19:55 2006
New Revision: 34561

Modified:
   pypy/dist/pypy/translator/c/src/exception.h
Log:
Eagerly normalize the exceptions escaping from RPython to CPython.  This
works around obscure troubles with non-normalized py.magic.AssertionError
exceptions.



Modified: pypy/dist/pypy/translator/c/src/exception.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/exception.h	(original)
+++ pypy/dist/pypy/translator/c/src/exception.h	Mon Nov 13 14:19:55 2006
@@ -79,19 +79,25 @@
 	/* XXX 1. uses officially bad fishing */
 	/* XXX 2. looks for exception classes by name, fragile */
 	char* clsname;
-	PyObject* pycls;
+	PyObject *pycls, *v, *tb;
 	assert(RPyExceptionOccurred());
 	assert(!PyErr_Occurred());
 	clsname = RPyFetchExceptionType()->ov_name->items;
 	pycls = PyDict_GetItemString(PyEval_GetBuiltins(), clsname);
 	if (pycls != NULL && PyExceptionClass_Check(pycls) &&
 	    PyObject_IsSubclass(pycls, PyExc_Exception)) {
-		PyErr_SetNone(pycls);
+		v = NULL;
 	}
 	else {
-		PyErr_SetString(RPythonError, clsname);
+		pycls = RPythonError;
+		v = PyString_FromString(clsname);
 	}
+	Py_INCREF(pycls);
+	tb = NULL;
 	RPyClearException();
+
+	PyErr_NormalizeException(&pycls, &v, &tb);
+	PyErr_Restore(pycls, v, tb);
 }
 #endif   /* !PYPY_STANDALONE */
 



More information about the Pypy-commit mailing list