diff options
author | Guido van Rossum <guido@python.org> | 2008-03-18 04:26:48 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2008-03-18 04:26:48 (GMT) |
commit | 504153d55b11aa8f622b6e4baa6a5e94ddfe96e2 (patch) | |
tree | 9f211d2f1445509b590af7b7d3942f93f8bc2425 | |
parent | a5573b31532f59a63d9ff24e415592f60f974da4 (diff) | |
download | cpython-504153d55b11aa8f622b6e4baa6a5e94ddfe96e2.zip cpython-504153d55b11aa8f622b6e4baa6a5e94ddfe96e2.tar.gz cpython-504153d55b11aa8f622b6e4baa6a5e94ddfe96e2.tar.bz2 |
Issue #2341: Add a Py3k warning when raising an exception that doesn't
derive from BaseException.
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Python/ceval.c | 9 |
2 files changed, 11 insertions, 1 deletions
@@ -13,7 +13,8 @@ Core and builtins ----------------- - Issue #2371: Add a Py3k warning when catching an exception that - doesn't derive from BaseException. + doesn't derive from BaseException. Issue #2341: Add a Py3k warning + when raising an exception that doesn't derive from BaseException. - Issue #2321: use pymalloc for unicode object string data to reduce memory usage in some circumstances. diff --git a/Python/ceval.c b/Python/ceval.c index d66d97e..dc1aa52 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3161,6 +3161,15 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb) type->ob_type->tp_name); goto raise_error; } + + assert(PyExceptionClass_Check(type)); + if (Py_Py3kWarningFlag && PyClass_Check(type)) { + if (PyErr_Warn(PyExc_DeprecationWarning, + "exceptions must derive from BaseException " + "in 3.x") == -1) + goto raise_error; + } + PyErr_Restore(type, value, tb); if (tb == NULL) return WHY_EXCEPTION; |