summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2003-01-10 15:31:15 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2003-01-10 15:31:15 (GMT)
commit37aa066164fb75288b3a05b620c95847908cf04b (patch)
tree96fd92808238a98c14524cb42f99b8d9b78a8d82
parent8e914d9a1d67e921e3e9e4209ee08c8e54eb2a7a (diff)
downloadcpython-37aa066164fb75288b3a05b620c95847908cf04b.zip
cpython-37aa066164fb75288b3a05b620c95847908cf04b.tar.gz
cpython-37aa066164fb75288b3a05b620c95847908cf04b.tar.bz2
As discussed briefly on python-dev, add Pending Deprecation Warning
when a string exception is raised. Note that raising string exceptions is deprecated in an exception message.
-rw-r--r--Python/ceval.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index b5fbd47..0c52c47 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2733,7 +2733,8 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb)
/* Raising builtin string is deprecated but still allowed --
* do nothing. Raising an instance of a new-style str
* subclass is right out. */
- ;
+ PyErr_Warn(PyExc_PendingDeprecationWarning,
+ "raising a string exception is deprecated");
else if (PyClass_Check(type))
PyErr_NormalizeException(&type, &value, &tb);
@@ -2757,8 +2758,9 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb)
/* Not something you can raise. You get an exception
anyway, just not what you specified :-) */
PyErr_Format(PyExc_TypeError,
- "exceptions must be strings, classes, or "
- "instances, not %s", type->ob_type->tp_name);
+ "exceptions must be classes, instances, or "
+ "strings (deprecated), not %s",
+ type->ob_type->tp_name);
goto raise_error;
}
PyErr_Restore(type, value, tb);