[pypy-svn] r72590 - in pypy/trunk/pypy/translator/c: . src
arigo at codespeak.net
arigo at codespeak.net
Mon Mar 22 20:08:06 CET 2010
Author: arigo
Date: Mon Mar 22 20:08:05 2010
New Revision: 72590
Modified:
pypy/trunk/pypy/translator/c/node.py
pypy/trunk/pypy/translator/c/src/exception.h
Log:
More workarounds for the py lib's BuiltinAssertionError.
Shows a test failure on CPython 2.6 in test_exception.py.
Modified: pypy/trunk/pypy/translator/c/node.py
==============================================================================
--- pypy/trunk/pypy/translator/c/node.py (original)
+++ pypy/trunk/pypy/translator/c/node.py Mon Mar 22 20:08:05 2010
@@ -928,9 +928,10 @@
import types, py
if isinstance(value, (type, types.ClassType)):
if (issubclass(value, BaseException) and
- (value.__module__ == 'exceptions'
- or value is py.code._AssertionError)):
+ value.__module__ == 'exceptions'):
return 'PyExc_' + value.__name__
+ if value is py.code._AssertionError:
+ return 'PyExc_AssertionError'
raise Exception("don't know how to simply render py object: %r" %
(value, ))
Modified: pypy/trunk/pypy/translator/c/src/exception.h
==============================================================================
--- pypy/trunk/pypy/translator/c/src/exception.h (original)
+++ pypy/trunk/pypy/translator/c/src/exception.h Mon Mar 22 20:08:05 2010
@@ -99,14 +99,18 @@
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)) {
- v = NULL;
+ v = NULL;
+ if (strcmp(clsname, "AssertionError") == 0) {
+ /* workaround against the py lib's BuiltinAssertionError */
+ pycls = PyExc_AssertionError;
}
else {
- pycls = PyExc_Exception; /* XXX RPythonError */
- v = PyString_FromString(clsname);
+ pycls = PyDict_GetItemString(PyEval_GetBuiltins(), clsname);
+ if (pycls == NULL || !PyExceptionClass_Check(pycls) ||
+ !PyObject_IsSubclass(pycls, PyExc_Exception)) {
+ pycls = PyExc_Exception; /* XXX RPythonError */
+ v = PyString_FromString(clsname);
+ }
}
Py_INCREF(pycls);
tb = NULL;
More information about the Pypy-commit
mailing list