Make Py3k warnings consistent w.r.t. punctuation; also respect the

EOL 80 limit and supply more alternatives in warning messages.
This commit is contained in:
Georg Brandl 2008-03-25 08:29:14 +00:00
parent 80055f6295
commit d5b635f196
16 changed files with 67 additions and 54 deletions

View file

@ -1363,7 +1363,7 @@ ast_for_atom(struct compiling *c, const node *n)
expr_ty expression;
if (Py_Py3kWarningFlag) {
if (PyErr_WarnExplicit(PyExc_DeprecationWarning,
"backquote not supported in 3.x",
"backquote not supported in 3.x; use repr()",
c->c_filename, LINENO(n),
NULL, NULL)) {
return NULL;

View file

@ -166,7 +166,8 @@ builtin_apply(PyObject *self, PyObject *args)
if (Py_Py3kWarningFlag &&
PyErr_Warn(PyExc_DeprecationWarning,
"apply() not supported in 3.x. Use func(*args, **kwargs).") < 0)
"apply() not supported in 3.x; "
"use func(*args, **kwargs)") < 0)
return NULL;
if (!PyArg_UnpackTuple(args, "apply", 1, 3, &func, &alist, &kwdict))
@ -225,7 +226,8 @@ builtin_callable(PyObject *self, PyObject *v)
{
if (Py_Py3kWarningFlag &&
PyErr_Warn(PyExc_DeprecationWarning,
"callable() not supported in 3.x. Use hasattr(o, '__call__').") < 0)
"callable() not supported in 3.x; "
"use hasattr(o, '__call__')") < 0)
return NULL;
return PyBool_FromLong((long)PyCallable_Check(v));
}
@ -684,7 +686,7 @@ builtin_execfile(PyObject *self, PyObject *args)
if (Py_Py3kWarningFlag &&
PyErr_Warn(PyExc_DeprecationWarning,
"execfile() not supported in 3.x. Use exec().") < 0)
"execfile() not supported in 3.x; use exec()") < 0)
return NULL;
if (!PyArg_ParseTuple(args, "s|O!O:execfile",
@ -912,7 +914,8 @@ builtin_map(PyObject *self, PyObject *args)
if (func == Py_None) {
if (Py_Py3kWarningFlag &&
PyErr_Warn(PyExc_DeprecationWarning,
"map(None, ...) not supported in 3.x. Use list(...).") < 0)
"map(None, ...) not supported in 3.x; "
"use list(...)") < 0)
return NULL;
if (n == 1) {
/* map(None, S) is the same as list(S). */
@ -1934,7 +1937,8 @@ builtin_reduce(PyObject *self, PyObject *args)
if (Py_Py3kWarningFlag &&
PyErr_Warn(PyExc_DeprecationWarning,
"reduce() not supported in 3.x") < 0)
"reduce() not supported in 3.x; "
"use functools.reduce()") < 0)
return NULL;
if (!PyArg_UnpackTuple(args, "reduce", 2, 3, &func, &seq, &result))
@ -2011,7 +2015,7 @@ builtin_reload(PyObject *self, PyObject *v)
{
if (Py_Py3kWarningFlag &&
PyErr_Warn(PyExc_DeprecationWarning,
"reload() not supported in 3.x") < 0)
"reload() not supported in 3.x; use imp.reload()") < 0)
return NULL;
return PyImport_ReloadModule(v);

View file

@ -4056,7 +4056,7 @@ assign_slice(PyObject *u, PyObject *v, PyObject *w, PyObject *x)
PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS))
#define CANNOT_CATCH_MSG "catching classes that don't inherit from " \
"BaseException is not allowed in 3.x."
"BaseException is not allowed in 3.x"
static PyObject *
cmp_outcome(int op, register PyObject *v, register PyObject *w)

View file

@ -174,8 +174,8 @@ sys_exc_clear(PyObject *self, PyObject *noargs)
if (Py_Py3kWarningFlag &&
PyErr_Warn(PyExc_DeprecationWarning,
"sys.exc_clear() not supported in 3.x. "
"Use except clauses.") < 0)
"sys.exc_clear() not supported in 3.x; "
"use except clauses") < 0)
return NULL;
tstate = PyThreadState_GET();