mirror of https://github.com/python/cpython.git
A little reformating of Py3k warnings
This commit is contained in:
parent
fe4948bcef
commit
f19a7b90bd
|
@ -1258,7 +1258,7 @@ static PyObject *
|
||||||
array_fromfile_as_read(arrayobject *self, PyObject *args)
|
array_fromfile_as_read(arrayobject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
if (PyErr_WarnPy3k("array.read() not supported in 3.x; "
|
if (PyErr_WarnPy3k("array.read() not supported in 3.x; "
|
||||||
"use array.fromfile()", 1) < 0)
|
"use array.fromfile()", 1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
return array_fromfile(self, args);
|
return array_fromfile(self, args);
|
||||||
}
|
}
|
||||||
|
@ -1297,7 +1297,7 @@ static PyObject *
|
||||||
array_tofile_as_write(arrayobject *self, PyObject *f)
|
array_tofile_as_write(arrayobject *self, PyObject *f)
|
||||||
{
|
{
|
||||||
if (PyErr_WarnPy3k("array.write() not supported in 3.x; "
|
if (PyErr_WarnPy3k("array.write() not supported in 3.x; "
|
||||||
"use array.tofile()", 1) < 0)
|
"use array.tofile()", 1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
return array_tofile(self, f);
|
return array_tofile(self, f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ cell_compare(PyCellObject *a, PyCellObject *b)
|
||||||
{
|
{
|
||||||
/* Py3K warning for comparisons */
|
/* Py3K warning for comparisons */
|
||||||
if (PyErr_WarnPy3k("cell comparisons not supported in 3.x",
|
if (PyErr_WarnPy3k("cell comparisons not supported in 3.x",
|
||||||
1) < 0) {
|
1) < 0) {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -339,9 +339,9 @@ code_richcompare(PyObject *self, PyObject *other, int op)
|
||||||
!PyCode_Check(other)) {
|
!PyCode_Check(other)) {
|
||||||
|
|
||||||
/* Py3K warning if types are not equal and comparison
|
/* Py3K warning if types are not equal and comparison
|
||||||
isn't == or != */
|
isn't == or != */
|
||||||
if (PyErr_WarnPy3k("code inequality comparisons not supported "
|
if (PyErr_WarnPy3k("code inequality comparisons not supported "
|
||||||
"in 3.x", 1) < 0) {
|
"in 3.x", 1) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1779,7 +1779,7 @@ dict_richcompare(PyObject *v, PyObject *w, int op)
|
||||||
else {
|
else {
|
||||||
/* Py3K warning if comparison isn't == or != */
|
/* Py3K warning if comparison isn't == or != */
|
||||||
if (PyErr_WarnPy3k("dict inequality comparisons not supported "
|
if (PyErr_WarnPy3k("dict inequality comparisons not supported "
|
||||||
"in 3.x", 1) < 0) {
|
"in 3.x", 1) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
res = Py_NotImplemented;
|
res = Py_NotImplemented;
|
||||||
|
@ -1810,7 +1810,7 @@ static PyObject *
|
||||||
dict_has_key(register PyDictObject *mp, PyObject *key)
|
dict_has_key(register PyDictObject *mp, PyObject *key)
|
||||||
{
|
{
|
||||||
if (PyErr_WarnPy3k("dict.has_key() not supported in 3.x; "
|
if (PyErr_WarnPy3k("dict.has_key() not supported in 3.x; "
|
||||||
"use the in operator", 1) < 0)
|
"use the in operator", 1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
return dict_contains(mp, key);
|
return dict_contains(mp, key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,9 +279,8 @@ BaseException_get_message(PyBaseExceptionObject *self)
|
||||||
int ret;
|
int ret;
|
||||||
ret = PyErr_WarnEx(PyExc_DeprecationWarning,
|
ret = PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||||
"BaseException.message has been deprecated as "
|
"BaseException.message has been deprecated as "
|
||||||
"of Python 2.6",
|
"of Python 2.6", 1);
|
||||||
1);
|
if (ret < 0)
|
||||||
if (ret == -1)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
Py_INCREF(self->message);
|
Py_INCREF(self->message);
|
||||||
|
@ -294,9 +293,8 @@ BaseException_set_message(PyBaseExceptionObject *self, PyObject *val)
|
||||||
int ret;
|
int ret;
|
||||||
ret = PyErr_WarnEx(PyExc_DeprecationWarning,
|
ret = PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||||
"BaseException.message has been deprecated as "
|
"BaseException.message has been deprecated as "
|
||||||
"of Python 2.6",
|
"of Python 2.6", 1);
|
||||||
1);
|
if (ret < 0)
|
||||||
if (ret == -1)
|
|
||||||
return -1;
|
return -1;
|
||||||
Py_INCREF(val);
|
Py_INCREF(val);
|
||||||
Py_DECREF(self->message);
|
Py_DECREF(self->message);
|
||||||
|
|
|
@ -627,8 +627,9 @@ file_seek(PyFileObject *f, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
/* Deprecated in 2.6 */
|
/* Deprecated in 2.6 */
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
if (PyErr_Warn(PyExc_DeprecationWarning,
|
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||||
"integer argument expected, got float"))
|
"integer argument expected, got float",
|
||||||
|
1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
off_index = offobj;
|
off_index = offobj;
|
||||||
Py_INCREF(offobj);
|
Py_INCREF(offobj);
|
||||||
|
|
|
@ -2038,7 +2038,7 @@ listsort(PyListObject *self, PyObject *args, PyObject *kwds)
|
||||||
if (compare == Py_None)
|
if (compare == Py_None)
|
||||||
compare = NULL;
|
compare = NULL;
|
||||||
if (compare != NULL &&
|
if (compare != NULL &&
|
||||||
PyErr_WarnPy3k("the cmp argument is not supported in 3.x", 1) < 0)
|
PyErr_WarnPy3k("the cmp argument is not supported in 3.x", 1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (keyfunc == Py_None)
|
if (keyfunc == Py_None)
|
||||||
keyfunc = NULL;
|
keyfunc = NULL;
|
||||||
|
|
|
@ -236,7 +236,7 @@ meth_richcompare(PyObject *self, PyObject *other, int op)
|
||||||
{
|
{
|
||||||
/* Py3K warning if types are not equal and comparison isn't == or != */
|
/* Py3K warning if types are not equal and comparison isn't == or != */
|
||||||
if (PyErr_WarnPy3k("builtin_function_or_method inequality "
|
if (PyErr_WarnPy3k("builtin_function_or_method inequality "
|
||||||
"comparisons not supported in 3.x", 1) < 0) {
|
"comparisons not supported in 3.x", 1) < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,9 +352,8 @@ Py_FindMethodInChain(PyMethodChain *chain, PyObject *self, const char *name)
|
||||||
{
|
{
|
||||||
if (name[0] == '_' && name[1] == '_') {
|
if (name[0] == '_' && name[1] == '_') {
|
||||||
if (strcmp(name, "__methods__") == 0) {
|
if (strcmp(name, "__methods__") == 0) {
|
||||||
if (Py_Py3kWarningFlag &&
|
if (PyErr_WarnPy3k("__methods__ not supported in 3.x",
|
||||||
PyErr_Warn(PyExc_DeprecationWarning,
|
1) < 0)
|
||||||
"__methods__ not supported in 3.x") < 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
return listmethodchain(chain);
|
return listmethodchain(chain);
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ builtin_apply(PyObject *self, PyObject *args)
|
||||||
PyObject *t = NULL, *retval = NULL;
|
PyObject *t = NULL, *retval = NULL;
|
||||||
|
|
||||||
if (PyErr_WarnPy3k("apply() not supported in 3.x; "
|
if (PyErr_WarnPy3k("apply() not supported in 3.x; "
|
||||||
"use func(*args, **kwargs)", 1) < 0)
|
"use func(*args, **kwargs)", 1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!PyArg_UnpackTuple(args, "apply", 1, 3, &func, &alist, &kwdict))
|
if (!PyArg_UnpackTuple(args, "apply", 1, 3, &func, &alist, &kwdict))
|
||||||
|
@ -224,7 +224,7 @@ static PyObject *
|
||||||
builtin_callable(PyObject *self, PyObject *v)
|
builtin_callable(PyObject *self, PyObject *v)
|
||||||
{
|
{
|
||||||
if (PyErr_WarnPy3k("callable() not supported in 3.x; "
|
if (PyErr_WarnPy3k("callable() not supported in 3.x; "
|
||||||
"use hasattr(o, '__call__')", 1) < 0)
|
"use hasattr(o, '__call__')", 1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
return PyBool_FromLong((long)PyCallable_Check(v));
|
return PyBool_FromLong((long)PyCallable_Check(v));
|
||||||
}
|
}
|
||||||
|
@ -704,7 +704,7 @@ builtin_execfile(PyObject *self, PyObject *args)
|
||||||
int exists;
|
int exists;
|
||||||
|
|
||||||
if (PyErr_WarnPy3k("execfile() not supported in 3.x; use exec()",
|
if (PyErr_WarnPy3k("execfile() not supported in 3.x; use exec()",
|
||||||
1) < 0)
|
1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "s|O!O:execfile",
|
if (!PyArg_ParseTuple(args, "s|O!O:execfile",
|
||||||
|
@ -931,7 +931,7 @@ builtin_map(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
if (func == Py_None) {
|
if (func == Py_None) {
|
||||||
if (PyErr_WarnPy3k("map(None, ...) not supported in 3.x; "
|
if (PyErr_WarnPy3k("map(None, ...) not supported in 3.x; "
|
||||||
"use list(...)", 1) < 0)
|
"use list(...)", 1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (n == 1) {
|
if (n == 1) {
|
||||||
/* map(None, S) is the same as list(S). */
|
/* map(None, S) is the same as list(S). */
|
||||||
|
@ -1959,7 +1959,7 @@ builtin_reduce(PyObject *self, PyObject *args)
|
||||||
PyObject *seq, *func, *result = NULL, *it;
|
PyObject *seq, *func, *result = NULL, *it;
|
||||||
|
|
||||||
if (PyErr_WarnPy3k("reduce() not supported in 3.x; "
|
if (PyErr_WarnPy3k("reduce() not supported in 3.x; "
|
||||||
"use functools.reduce()", 1) < 0)
|
"use functools.reduce()", 1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!PyArg_UnpackTuple(args, "reduce", 2, 3, &func, &seq, &result))
|
if (!PyArg_UnpackTuple(args, "reduce", 2, 3, &func, &seq, &result))
|
||||||
|
@ -2035,7 +2035,7 @@ static PyObject *
|
||||||
builtin_reload(PyObject *self, PyObject *v)
|
builtin_reload(PyObject *self, PyObject *v)
|
||||||
{
|
{
|
||||||
if (PyErr_WarnPy3k("In 3.x, reload() is renamed to imp.reload()",
|
if (PyErr_WarnPy3k("In 3.x, reload() is renamed to imp.reload()",
|
||||||
1) < 0)
|
1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyImport_ReloadModule(v);
|
return PyImport_ReloadModule(v);
|
||||||
|
|
|
@ -3157,16 +3157,16 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb)
|
||||||
/* Not something you can raise. You get an exception
|
/* Not something you can raise. You get an exception
|
||||||
anyway, just not what you specified :-) */
|
anyway, just not what you specified :-) */
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"exceptions must be classes or instances, not %s",
|
"exceptions must be classes or instances, not %s",
|
||||||
type->ob_type->tp_name);
|
type->ob_type->tp_name);
|
||||||
goto raise_error;
|
goto raise_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(PyExceptionClass_Check(type));
|
assert(PyExceptionClass_Check(type));
|
||||||
if (Py_Py3kWarningFlag && PyClass_Check(type)) {
|
if (Py_Py3kWarningFlag && PyClass_Check(type)) {
|
||||||
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||||
"exceptions must derive from BaseException "
|
"exceptions must derive from BaseException "
|
||||||
"in 3.x", 1) == -1)
|
"in 3.x", 1) < 0)
|
||||||
goto raise_error;
|
goto raise_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4092,7 +4092,7 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
|
||||||
PyExc_DeprecationWarning,
|
PyExc_DeprecationWarning,
|
||||||
"catching of string "
|
"catching of string "
|
||||||
"exceptions is deprecated", 1);
|
"exceptions is deprecated", 1);
|
||||||
if (ret_val == -1)
|
if (ret_val < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else if (Py_Py3kWarningFlag &&
|
else if (Py_Py3kWarningFlag &&
|
||||||
|
@ -4103,7 +4103,7 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
|
||||||
ret_val = PyErr_WarnEx(
|
ret_val = PyErr_WarnEx(
|
||||||
PyExc_DeprecationWarning,
|
PyExc_DeprecationWarning,
|
||||||
CANNOT_CATCH_MSG, 1);
|
CANNOT_CATCH_MSG, 1);
|
||||||
if (ret_val == -1)
|
if (ret_val < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4115,7 +4115,7 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
|
||||||
PyExc_DeprecationWarning,
|
PyExc_DeprecationWarning,
|
||||||
"catching of string "
|
"catching of string "
|
||||||
"exceptions is deprecated", 1);
|
"exceptions is deprecated", 1);
|
||||||
if (ret_val == -1)
|
if (ret_val < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else if (Py_Py3kWarningFlag &&
|
else if (Py_Py3kWarningFlag &&
|
||||||
|
@ -4126,7 +4126,7 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
|
||||||
ret_val = PyErr_WarnEx(
|
ret_val = PyErr_WarnEx(
|
||||||
PyExc_DeprecationWarning,
|
PyExc_DeprecationWarning,
|
||||||
CANNOT_CATCH_MSG, 1);
|
CANNOT_CATCH_MSG, 1);
|
||||||
if (ret_val == -1)
|
if (ret_val < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ sys_exc_clear(PyObject *self, PyObject *noargs)
|
||||||
PyObject *tmp_type, *tmp_value, *tmp_tb;
|
PyObject *tmp_type, *tmp_value, *tmp_tb;
|
||||||
|
|
||||||
if (PyErr_WarnPy3k("sys.exc_clear() not supported in 3.x; "
|
if (PyErr_WarnPy3k("sys.exc_clear() not supported in 3.x; "
|
||||||
"use except clauses", 1) < 0)
|
"use except clauses", 1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
tstate = PyThreadState_GET();
|
tstate = PyThreadState_GET();
|
||||||
|
|
Loading…
Reference in New Issue