Skip to content

Commit 5fe32ab

Browse files
author
benjamin.peterson
committed
A little reformating of Py3k warnings
git-svn-id: http://svn.python.org/projects/python/trunk@62536 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 18f2223 commit 5fe32ab

11 files changed

Lines changed: 33 additions & 35 deletions

File tree

Modules/arraymodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ static PyObject *
12581258
array_fromfile_as_read(arrayobject *self, PyObject *args)
12591259
{
12601260
if (PyErr_WarnPy3k("array.read() not supported in 3.x; "
1261-
"use array.fromfile()", 1) < 0)
1261+
"use array.fromfile()", 1) < 0)
12621262
return NULL;
12631263
return array_fromfile(self, args);
12641264
}
@@ -1297,7 +1297,7 @@ static PyObject *
12971297
array_tofile_as_write(arrayobject *self, PyObject *f)
12981298
{
12991299
if (PyErr_WarnPy3k("array.write() not supported in 3.x; "
1300-
"use array.tofile()", 1) < 0)
1300+
"use array.tofile()", 1) < 0)
13011301
return NULL;
13021302
return array_tofile(self, f);
13031303
}

Objects/cellobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ cell_compare(PyCellObject *a, PyCellObject *b)
5656
{
5757
/* Py3K warning for comparisons */
5858
if (PyErr_WarnPy3k("cell comparisons not supported in 3.x",
59-
1) < 0) {
59+
1) < 0) {
6060
return -2;
6161
}
6262

Objects/codeobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,9 @@ code_richcompare(PyObject *self, PyObject *other, int op)
339339
!PyCode_Check(other)) {
340340

341341
/* Py3K warning if types are not equal and comparison
342-
isn't == or != */
342+
isn't == or != */
343343
if (PyErr_WarnPy3k("code inequality comparisons not supported "
344-
"in 3.x", 1) < 0) {
344+
"in 3.x", 1) < 0) {
345345
return NULL;
346346
}
347347

Objects/dictobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ dict_richcompare(PyObject *v, PyObject *w, int op)
17791779
else {
17801780
/* Py3K warning if comparison isn't == or != */
17811781
if (PyErr_WarnPy3k("dict inequality comparisons not supported "
1782-
"in 3.x", 1) < 0) {
1782+
"in 3.x", 1) < 0) {
17831783
return NULL;
17841784
}
17851785
res = Py_NotImplemented;
@@ -1810,7 +1810,7 @@ static PyObject *
18101810
dict_has_key(register PyDictObject *mp, PyObject *key)
18111811
{
18121812
if (PyErr_WarnPy3k("dict.has_key() not supported in 3.x; "
1813-
"use the in operator", 1) < 0)
1813+
"use the in operator", 1) < 0)
18141814
return NULL;
18151815
return dict_contains(mp, key);
18161816
}

Objects/exceptions.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,8 @@ BaseException_get_message(PyBaseExceptionObject *self)
279279
int ret;
280280
ret = PyErr_WarnEx(PyExc_DeprecationWarning,
281281
"BaseException.message has been deprecated as "
282-
"of Python 2.6",
283-
1);
284-
if (ret == -1)
282+
"of Python 2.6", 1);
283+
if (ret < 0)
285284
return NULL;
286285

287286
Py_INCREF(self->message);
@@ -294,9 +293,8 @@ BaseException_set_message(PyBaseExceptionObject *self, PyObject *val)
294293
int ret;
295294
ret = PyErr_WarnEx(PyExc_DeprecationWarning,
296295
"BaseException.message has been deprecated as "
297-
"of Python 2.6",
298-
1);
299-
if (ret == -1)
296+
"of Python 2.6", 1);
297+
if (ret < 0)
300298
return -1;
301299
Py_INCREF(val);
302300
Py_DECREF(self->message);

Objects/fileobject.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,9 @@ file_seek(PyFileObject *f, PyObject *args)
627627
return NULL;
628628
/* Deprecated in 2.6 */
629629
PyErr_Clear();
630-
if (PyErr_Warn(PyExc_DeprecationWarning,
631-
"integer argument expected, got float"))
630+
if (PyErr_WarnEx(PyExc_DeprecationWarning,
631+
"integer argument expected, got float",
632+
1) < 0)
632633
return NULL;
633634
off_index = offobj;
634635
Py_INCREF(offobj);

Objects/listobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2038,7 +2038,7 @@ listsort(PyListObject *self, PyObject *args, PyObject *kwds)
20382038
if (compare == Py_None)
20392039
compare = NULL;
20402040
if (compare != NULL &&
2041-
PyErr_WarnPy3k("the cmp argument is not supported in 3.x", 1) < 0)
2041+
PyErr_WarnPy3k("the cmp argument is not supported in 3.x", 1) < 0)
20422042
return NULL;
20432043
if (keyfunc == Py_None)
20442044
keyfunc = NULL;

Objects/methodobject.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ meth_richcompare(PyObject *self, PyObject *other, int op)
236236
{
237237
/* Py3K warning if types are not equal and comparison isn't == or != */
238238
if (PyErr_WarnPy3k("builtin_function_or_method inequality "
239-
"comparisons not supported in 3.x", 1) < 0) {
239+
"comparisons not supported in 3.x", 1) < 0) {
240240
return NULL;
241241
}
242242

@@ -352,9 +352,8 @@ Py_FindMethodInChain(PyMethodChain *chain, PyObject *self, const char *name)
352352
{
353353
if (name[0] == '_' && name[1] == '_') {
354354
if (strcmp(name, "__methods__") == 0) {
355-
if (Py_Py3kWarningFlag &&
356-
PyErr_Warn(PyExc_DeprecationWarning,
357-
"__methods__ not supported in 3.x") < 0)
355+
if (PyErr_WarnPy3k("__methods__ not supported in 3.x",
356+
1) < 0)
358357
return NULL;
359358
return listmethodchain(chain);
360359
}

Python/bltinmodule.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ builtin_apply(PyObject *self, PyObject *args)
166166
PyObject *t = NULL, *retval = NULL;
167167

168168
if (PyErr_WarnPy3k("apply() not supported in 3.x; "
169-
"use func(*args, **kwargs)", 1) < 0)
169+
"use func(*args, **kwargs)", 1) < 0)
170170
return NULL;
171171

172172
if (!PyArg_UnpackTuple(args, "apply", 1, 3, &func, &alist, &kwdict))
@@ -224,7 +224,7 @@ static PyObject *
224224
builtin_callable(PyObject *self, PyObject *v)
225225
{
226226
if (PyErr_WarnPy3k("callable() not supported in 3.x; "
227-
"use hasattr(o, '__call__')", 1) < 0)
227+
"use hasattr(o, '__call__')", 1) < 0)
228228
return NULL;
229229
return PyBool_FromLong((long)PyCallable_Check(v));
230230
}
@@ -704,7 +704,7 @@ builtin_execfile(PyObject *self, PyObject *args)
704704
int exists;
705705

706706
if (PyErr_WarnPy3k("execfile() not supported in 3.x; use exec()",
707-
1) < 0)
707+
1) < 0)
708708
return NULL;
709709

710710
if (!PyArg_ParseTuple(args, "s|O!O:execfile",
@@ -931,7 +931,7 @@ builtin_map(PyObject *self, PyObject *args)
931931

932932
if (func == Py_None) {
933933
if (PyErr_WarnPy3k("map(None, ...) not supported in 3.x; "
934-
"use list(...)", 1) < 0)
934+
"use list(...)", 1) < 0)
935935
return NULL;
936936
if (n == 1) {
937937
/* map(None, S) is the same as list(S). */
@@ -1959,7 +1959,7 @@ builtin_reduce(PyObject *self, PyObject *args)
19591959
PyObject *seq, *func, *result = NULL, *it;
19601960

19611961
if (PyErr_WarnPy3k("reduce() not supported in 3.x; "
1962-
"use functools.reduce()", 1) < 0)
1962+
"use functools.reduce()", 1) < 0)
19631963
return NULL;
19641964

19651965
if (!PyArg_UnpackTuple(args, "reduce", 2, 3, &func, &seq, &result))
@@ -2035,7 +2035,7 @@ static PyObject *
20352035
builtin_reload(PyObject *self, PyObject *v)
20362036
{
20372037
if (PyErr_WarnPy3k("In 3.x, reload() is renamed to imp.reload()",
2038-
1) < 0)
2038+
1) < 0)
20392039
return NULL;
20402040

20412041
return PyImport_ReloadModule(v);

Python/ceval.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3157,16 +3157,16 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb)
31573157
/* Not something you can raise. You get an exception
31583158
anyway, just not what you specified :-) */
31593159
PyErr_Format(PyExc_TypeError,
3160-
"exceptions must be classes or instances, not %s",
3161-
type->ob_type->tp_name);
3160+
"exceptions must be classes or instances, not %s",
3161+
type->ob_type->tp_name);
31623162
goto raise_error;
31633163
}
31643164

31653165
assert(PyExceptionClass_Check(type));
31663166
if (Py_Py3kWarningFlag && PyClass_Check(type)) {
31673167
if (PyErr_WarnEx(PyExc_DeprecationWarning,
3168-
"exceptions must derive from BaseException "
3169-
"in 3.x", 1) == -1)
3168+
"exceptions must derive from BaseException "
3169+
"in 3.x", 1) < 0)
31703170
goto raise_error;
31713171
}
31723172

@@ -4092,7 +4092,7 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
40924092
PyExc_DeprecationWarning,
40934093
"catching of string "
40944094
"exceptions is deprecated", 1);
4095-
if (ret_val == -1)
4095+
if (ret_val < 0)
40964096
return NULL;
40974097
}
40984098
else if (Py_Py3kWarningFlag &&
@@ -4103,7 +4103,7 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
41034103
ret_val = PyErr_WarnEx(
41044104
PyExc_DeprecationWarning,
41054105
CANNOT_CATCH_MSG, 1);
4106-
if (ret_val == -1)
4106+
if (ret_val < 0)
41074107
return NULL;
41084108
}
41094109
}
@@ -4115,7 +4115,7 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
41154115
PyExc_DeprecationWarning,
41164116
"catching of string "
41174117
"exceptions is deprecated", 1);
4118-
if (ret_val == -1)
4118+
if (ret_val < 0)
41194119
return NULL;
41204120
}
41214121
else if (Py_Py3kWarningFlag &&
@@ -4126,7 +4126,7 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
41264126
ret_val = PyErr_WarnEx(
41274127
PyExc_DeprecationWarning,
41284128
CANNOT_CATCH_MSG, 1);
4129-
if (ret_val == -1)
4129+
if (ret_val < 0)
41304130
return NULL;
41314131
}
41324132
}

0 commit comments

Comments
 (0)