diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py index a5fe68ab7e3c06..c0c7ca1502ce92 100644 --- a/Lib/test/test_py3kwarn.py +++ b/Lib/test/test_py3kwarn.py @@ -258,6 +258,22 @@ class C: c = C() with check_py3k_warnings() as w: self.assertWarning(dir(c), w, expected) + + def test_sys_exc_info(self): + expected = 'sys.exc_info() not supported in 3.x: use except clauses.' + with check_py3k_warnings() as w: + self.assertWarning(sys.exc_info(), w, expected) + + def test_exception_iterable(self): + def helperftn(): + try: + pass + except RuntimeError as (num, message): + return None + expected = "Iterable exceptions are not supported in 3.x: access the arguments through the 'args' attribute instead" + with check_py3k_warnings() as w: + self.assertWarning(helperftn, w, expected) + def test_softspace(self): expected = 'file.softspace not supported in 3.x' diff --git a/Python/ceval.c b/Python/ceval.c index e1140a8e401243..564ed3401b460d 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4870,7 +4870,11 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w) CANNOT_CATCH_MSG, 1); if (ret_val < 0) return NULL; - } + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "Iterable exceptions are not supported in 3.x" + "access the arguments through the 'args' attribute instead", 1) < 0) + return NULL; + } } } else { diff --git a/Python/sysmodule.c b/Python/sysmodule.c index fdb7af2f5f6764..ccaefd91326742 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -149,6 +149,14 @@ PyDoc_STRVAR(excepthook_doc, static PyObject * sys_exc_info(PyObject *self, PyObject *noargs) { + if (Py_Py3kWarningFlag) { + if (PyErr_WarnExplicit_WithFix(PyExc_Py3xWarning, + "sys.exc_info() not supported in 3.x", + "use except clauses", NULL, NULL, + NULL, NULL)) { + return NULL; + } + } PyThreadState *tstate; tstate = PyThreadState_GET(); return Py_BuildValue(