Make Py3k warnings consistent w.r.t. punctuation; also respect the
EOL 80 limit and supply more alternatives in warning messages.
diff --git a/Objects/bufferobject.c b/Objects/bufferobject.c
index 0a818d6..fb7e1ef 100644
--- a/Objects/bufferobject.c
+++ b/Objects/bufferobject.c
@@ -231,7 +231,8 @@
{
if (Py_Py3kWarningFlag &&
PyErr_WarnEx(PyExc_DeprecationWarning,
- "buffer will be removed in 3.x", 1) < 0)
+ "buffer() not supported in 3.x; "
+ "use memoryview()", 1) < 0)
return NULL;
PyObject *ob;
diff --git a/Objects/cellobject.c b/Objects/cellobject.c
index 2286aaf..b86739e 100644
--- a/Objects/cellobject.c
+++ b/Objects/cellobject.c
@@ -55,8 +55,9 @@
cell_compare(PyCellObject *a, PyCellObject *b)
{
/* Py3K warning for comparisons */
- if (Py_Py3kWarningFlag && PyErr_Warn(PyExc_DeprecationWarning,
- "cell comparisons not supported in 3.x.") < 0) {
+ if (Py_Py3kWarningFlag &&
+ PyErr_Warn(PyExc_DeprecationWarning,
+ "cell comparisons not supported in 3.x") < 0) {
return -2;
}
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index 57cd2e6..33b4610 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -338,9 +338,12 @@
!PyCode_Check(self) ||
!PyCode_Check(other)) {
- /* Py3K warning if types are not equal and comparison isn't == or != */
- if (Py_Py3kWarningFlag && PyErr_Warn(PyExc_DeprecationWarning,
- "code inequality comparisons not supported in 3.x.") < 0) {
+ /* Py3K warning if types are not equal and comparison
+ isn't == or != */
+ if (Py_Py3kWarningFlag &&
+ PyErr_Warn(PyExc_DeprecationWarning,
+ "code inequality comparisons not supported "
+ "in 3.x") < 0) {
return NULL;
}
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 1ca2830..b897118 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1778,8 +1778,10 @@
}
else {
/* Py3K warning if comparison isn't == or != */
- if (Py_Py3kWarningFlag && PyErr_Warn(PyExc_DeprecationWarning,
- "dict inequality comparisons not supported in 3.x.") < 0) {
+ if (Py_Py3kWarningFlag &&
+ PyErr_Warn(PyExc_DeprecationWarning,
+ "dict inequality comparisons not supported "
+ "in 3.x") < 0) {
return NULL;
}
res = Py_NotImplemented;
@@ -1811,7 +1813,8 @@
{
if (Py_Py3kWarningFlag &&
PyErr_Warn(PyExc_DeprecationWarning,
- "dict.has_key() not supported in 3.x") < 0)
+ "dict.has_key() not supported in 3.x; "
+ "use the in operator") < 0)
return NULL;
return dict_contains(mp, key);
}
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 7fecb35..ec17bc2 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -190,10 +190,10 @@
BaseException_getitem(PyBaseExceptionObject *self, Py_ssize_t index)
{
if (Py_Py3kWarningFlag) {
- if (PyErr_Warn(PyExc_DeprecationWarning,
- "In 3.x, __getitem__ is not supported for exception "
- "classes, use args attribute") == -1)
- return NULL;
+ if (PyErr_Warn(PyExc_DeprecationWarning,
+ "__getitem__ not supported for exception "
+ "classes in 3.x; use args attribute") == -1)
+ return NULL;
}
return PySequence_GetItem(self->args, index);
}
@@ -203,10 +203,10 @@
Py_ssize_t start, Py_ssize_t stop)
{
if (Py_Py3kWarningFlag) {
- if (PyErr_Warn(PyExc_DeprecationWarning,
- "In 3.x, __getslice__ is not supported for exception "
- "classes, use args attribute") == -1)
- return NULL;
+ if (PyErr_Warn(PyExc_DeprecationWarning,
+ "__getslice__ not supported for exception "
+ "classes in 3.x; use args attribute") == -1)
+ return NULL;
}
return PySequence_GetSlice(self->args, start, stop);
}
diff --git a/Objects/listobject.c b/Objects/listobject.c
index d4faf0a..81617e4 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -2040,7 +2040,7 @@
if (compare != NULL &&
Py_Py3kWarningFlag &&
PyErr_Warn(PyExc_DeprecationWarning,
- "In 3.x, the cmp argument is no longer supported.") < 0)
+ "the cmp argument is not supported in 3.x") < 0)
return NULL;
if (keyfunc == Py_None)
keyfunc = NULL;
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index 16175f9..e641df1 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -235,9 +235,10 @@
!PyCFunction_Check(other))
{
/* Py3K warning if types are not equal and comparison isn't == or != */
- if (Py_Py3kWarningFlag && PyErr_Warn(PyExc_DeprecationWarning,
- "builtin_function_or_method "
- "inequality comparisons not supported in 3.x.") < 0) {
+ if (Py_Py3kWarningFlag &&
+ PyErr_Warn(PyExc_DeprecationWarning,
+ "builtin_function_or_method inequality "
+ "comparisons not supported in 3.x") < 0) {
return NULL;
}
@@ -353,12 +354,10 @@
{
if (name[0] == '_' && name[1] == '_') {
if (strcmp(name, "__methods__") == 0) {
- if (Py_Py3kWarningFlag) {
- if (PyErr_Warn(PyExc_DeprecationWarning,
- "__methods__ not supported "
- "in 3.x") < 0)
- return NULL;
- }
+ if (Py_Py3kWarningFlag &&
+ PyErr_Warn(PyExc_DeprecationWarning,
+ "__methods__ not supported in 3.x") < 0)
+ return NULL;
return listmethodchain(chain);
}
if (strcmp(name, "__doc__") == 0) {
diff --git a/Objects/object.c b/Objects/object.c
index 4a66f4f..e3377f3 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -867,9 +867,10 @@
/* Py3K warning if types are not equal and comparison isn't == or != */
if (Py_Py3kWarningFlag &&
- v->ob_type != w->ob_type && op != Py_EQ && op != Py_NE &&
- PyErr_Warn(PyExc_DeprecationWarning,
- "comparing unequal types not supported in 3.x.") < 0) {
+ v->ob_type != w->ob_type && op != Py_EQ && op != Py_NE &&
+ PyErr_Warn(PyExc_DeprecationWarning,
+ "comparing unequal types not supported "
+ "in 3.x") < 0) {
return NULL;
}
@@ -1691,8 +1692,8 @@
(strcmp(attrname, "__members__") == 0 ||
strcmp(attrname, "__methods__") == 0)) {
if (PyErr_Warn(PyExc_DeprecationWarning,
- "__members__ and __methods__ not supported "
- "in 3.x") < 0) {
+ "__members__ and __methods__ not "
+ "supported in 3.x") < 0) {
Py_XDECREF(list);
return -1;
}
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 82ced39..214e601 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -609,7 +609,8 @@
/* Py3K warning if comparison isn't == or != */
if (Py_Py3kWarningFlag && op != Py_EQ && op != Py_NE &&
PyErr_Warn(PyExc_DeprecationWarning,
- "type inequality comparisons not supported in 3.x.") < 0) {
+ "type inequality comparisons not supported "
+ "in 3.x") < 0) {
return NULL;
}