From 23d54261a7ae09b4217acf5b2e84cd1541e38c03 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 12 Feb 2013 20:23:56 +0100 Subject: [PATCH] implement 'raise ... from None' in Py3.3 --HG-- extra : rebase_source : 9ad9c4ea052a3eae0888f02a07ba4c40d62ddddf --- Cython/Utility/Exceptions.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Cython/Utility/Exceptions.c b/Cython/Utility/Exceptions.c index 252aa10..2c11287 100644 --- a/Cython/Utility/Exceptions.c +++ b/Cython/Utility/Exceptions.c @@ -186,9 +186,13 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject goto bad; } - if (cause && cause != Py_None) { + if (cause) { PyObject *fixed_cause; - if (PyExceptionClass_Check(cause)) { + if (cause == Py_None) { + /* raise ... from None */ + Py_DECREF(cause); + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; -- 2.7.4