[pypy-commit] pypy py3k: cpyext: fixes in pyerror.py
amauryfa
noreply at buildbot.pypy.org
Fri Sep 21 23:53:30 CEST 2012
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r57463:2dfdeaf2ab5c
Date: 2012-09-21 23:19 +0200
http://bitbucket.org/pypy/pypy/changeset/2dfdeaf2ab5c/
Log: cpyext: fixes in pyerror.py
diff --git a/pypy/module/cpyext/pyerrors.py b/pypy/module/cpyext/pyerrors.py
--- a/pypy/module/cpyext/pyerrors.py
+++ b/pypy/module/cpyext/pyerrors.py
@@ -186,7 +186,10 @@
w_given_type = space.type(w_given)
else:
w_given_type = w_given
- return space.exception_match(w_given_type, w_exc)
+ try:
+ return space.exception_match(w_given_type, w_exc)
+ except:
+ return 0
@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
def PyErr_ExceptionMatches(space, w_exc):
diff --git a/pypy/module/cpyext/test/test_pyerrors.py b/pypy/module/cpyext/test/test_pyerrors.py
--- a/pypy/module/cpyext/test/test_pyerrors.py
+++ b/pypy/module/cpyext/test/test_pyerrors.py
@@ -10,21 +10,12 @@
class TestExceptions(BaseApiTest):
def test_GivenExceptionMatches(self, space, api):
- old_style_exception = space.appexec([], """():
- class OldStyle:
- pass
- return OldStyle
- """)
exc_matches = api.PyErr_GivenExceptionMatches
string_exception = space.wrap('exception')
instance = space.call_function(space.w_ValueError)
- old_style_instance = space.call_function(old_style_exception)
assert exc_matches(string_exception, string_exception)
- assert exc_matches(old_style_exception, old_style_exception)
- assert not exc_matches(old_style_exception, space.w_Exception)
assert exc_matches(instance, space.w_ValueError)
- assert exc_matches(old_style_instance, old_style_exception)
assert exc_matches(space.w_ValueError, space.w_ValueError)
assert exc_matches(space.w_IndexError, space.w_LookupError)
assert not exc_matches(space.w_ValueError, space.w_LookupError)
@@ -151,7 +142,7 @@
PyErr_Fetch(&type, &val, &tb);
if (type != PyExc_TypeError)
Py_RETURN_FALSE;
- if (!PyString_Check(val))
+ if (!PyUnicode_Check(val))
Py_RETURN_FALSE;
/* Normalize */
PyErr_NormalizeException(&type, &val, &tb);
More information about the pypy-commit
mailing list