diff -r bbed36370b08 Lib/test/test_raise.py --- a/Lib/test/test_raise.py Thu Jan 12 22:46:19 2012 +0100 +++ b/Lib/test/test_raise.py Thu Jan 26 14:39:14 2012 -0800 @@ -67,6 +67,17 @@ class TestRaise(unittest.TestCase): raise self.assertRaises(KeyError, reraise) + def test_raise_from_None(self): + try: + try: + raise IndexError() + except IndexError as e: + raise ValueError() from None + except ValueError as exc2: + self.assertIsNone(exc2.__context__) + else: + self.fail("No exception raised") + def test_nested_reraise(self): def nested_reraise(): raise diff -r bbed36370b08 Python/ceval.c --- a/Python/ceval.c Thu Jan 12 22:46:19 2012 +0100 +++ b/Python/ceval.c Thu Jan 26 14:39:14 2012 -0800 @@ -3528,6 +3528,22 @@ do_raise(PyObject *exc, PyObject *cause) else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; } + else if (cause == Py_None) { + /* get rid of previous context by setting the current + thread's exception information to the replacement exception */ + PyThreadState *tstate = PyThreadState_GET(); + PyObject *old_type, *old_value; + old_type = tstate->exc_type; + old_value = tstate->exc_value; + tstate->exc_type = type; + tstate->exc_value = value; + Py_INCREF(type); + Py_INCREF(value); + fixed_cause = NULL; + Py_DECREF(cause); + Py_DECREF(old_type); + Py_DECREF(old_value); + } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from "