[Python-checkins] r61879 - in python/trunk: Doc/whatsnew/2.6.rst Lib/test/test_py3kwarn.py Objects/bufferobject.c Objects/cellobject.c Objects/codeobject.c Objects/dictobject.c Objects/exceptions.c Objects/listobject.c Objects/methodobject.c Objects/object.c Objects/typeobject.c Parser/tokenizer.c Python/ast.c Python/bltinmodule.c Python/ceval.c Python/sysmodule.c

georg.brandl python-checkins at python.org
Tue Mar 25 09:29:15 CET 2008


Author: georg.brandl
Date: Tue Mar 25 09:29:14 2008
New Revision: 61879
Modified:
 python/trunk/Doc/whatsnew/2.6.rst
 python/trunk/Lib/test/test_py3kwarn.py
 python/trunk/Objects/bufferobject.c
 python/trunk/Objects/cellobject.c
 python/trunk/Objects/codeobject.c
 python/trunk/Objects/dictobject.c
 python/trunk/Objects/exceptions.c
 python/trunk/Objects/listobject.c
 python/trunk/Objects/methodobject.c
 python/trunk/Objects/object.c
 python/trunk/Objects/typeobject.c
 python/trunk/Parser/tokenizer.c
 python/trunk/Python/ast.c
 python/trunk/Python/bltinmodule.c
 python/trunk/Python/ceval.c
 python/trunk/Python/sysmodule.c
Log:
Make Py3k warnings consistent w.r.t. punctuation; also respect the
EOL 80 limit and supply more alternatives in warning messages.
Modified: python/trunk/Doc/whatsnew/2.6.rst
==============================================================================
--- python/trunk/Doc/whatsnew/2.6.rst	(original)
+++ python/trunk/Doc/whatsnew/2.6.rst	Tue Mar 25 09:29:14 2008
@@ -93,7 +93,7 @@
 about features that will be removed in Python 3.0. You can run code
 with this switch to see how much work will be necessary to port
 code to 3.0. The value of this switch is available 
-to Python code as the boolean variable ``sys.py3kwarning``,
+to Python code as the boolean variable :data:`sys.py3kwarning`,
 and to C extension code as :cdata:`Py_Py3kWarningFlag`.
 
 Python 3.0 adds several new built-in functions and change the
Modified: python/trunk/Lib/test/test_py3kwarn.py
==============================================================================
--- python/trunk/Lib/test/test_py3kwarn.py	(original)
+++ python/trunk/Lib/test/test_py3kwarn.py	Tue Mar 25 09:29:14 2008
@@ -11,21 +11,21 @@
 class TestPy3KWarnings(unittest.TestCase):
 
 def test_type_inequality_comparisons(self):
- expected = 'type inequality comparisons not supported in 3.x.'
+ expected = 'type inequality comparisons not supported in 3.x'
 with catch_warning() as w:
 self.assertWarning(int < str, w, expected)
 with catch_warning() as w:
 self.assertWarning(type < object, w, expected)
 
 def test_object_inequality_comparisons(self):
- expected = 'comparing unequal types not supported in 3.x.'
+ expected = 'comparing unequal types not supported in 3.x'
 with catch_warning() as w:
 self.assertWarning(str < [], w, expected)
 with catch_warning() as w:
 self.assertWarning(object() < (1, 2), w, expected)
 
 def test_dict_inequality_comparisons(self):
- expected = 'dict inequality comparisons not supported in 3.x.'
+ expected = 'dict inequality comparisons not supported in 3.x'
 with catch_warning() as w:
 self.assertWarning({} < {2:3}, w, expected)
 with catch_warning() as w:
@@ -36,7 +36,7 @@
 self.assertWarning({2:3} >= {}, w, expected)
 
 def test_cell_inequality_comparisons(self):
- expected = 'cell comparisons not supported in 3.x.'
+ expected = 'cell comparisons not supported in 3.x'
 def f(x):
 def g():
 return x
@@ -49,7 +49,7 @@
 self.assertWarning(cell0 < cell1, w, expected)
 
 def test_code_inequality_comparisons(self):
- expected = 'code inequality comparisons not supported in 3.x.'
+ expected = 'code inequality comparisons not supported in 3.x'
 def f(x):
 pass
 def g(x):
@@ -65,7 +65,7 @@
 
 def test_builtin_function_or_method_comparisons(self):
 expected = ('builtin_function_or_method '
- 'inequality comparisons not supported in 3.x.')
+ 'inequality comparisons not supported in 3.x')
 func = eval
 meth = {}.get
 with catch_warning() as w:
@@ -81,7 +81,7 @@
 self.assertEqual(str(warning.message), expected_message)
 
 def test_sort_cmp_arg(self):
- expected = "In 3.x, the cmp argument is no longer supported."
+ expected = "the cmp argument is not supported in 3.x"
 lst = range(5)
 cmp = lambda x,y: -1
 
@@ -95,7 +95,7 @@
 self.assertWarning(sorted(lst, cmp), w, expected)
 
 def test_sys_exc_clear(self):
- expected = 'sys.exc_clear() not supported in 3.x. Use except clauses.'
+ expected = 'sys.exc_clear() not supported in 3.x; use except clauses'
 with catch_warning() as w:
 self.assertWarning(sys.exc_clear(), w, expected)
 
@@ -119,7 +119,7 @@
 self.assertWarning(set(), w, expected)
 
 def test_buffer(self):
- expected = 'buffer will be removed in 3.x'
+ expected = 'buffer() not supported in 3.x; use memoryview()'
 with catch_warning() as w:
 self.assertWarning(buffer('a'), w, expected)
 
Modified: python/trunk/Objects/bufferobject.c
==============================================================================
--- python/trunk/Objects/bufferobject.c	(original)
+++ python/trunk/Objects/bufferobject.c	Tue Mar 25 09:29:14 2008
@@ -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;
Modified: python/trunk/Objects/cellobject.c
==============================================================================
--- python/trunk/Objects/cellobject.c	(original)
+++ python/trunk/Objects/cellobject.c	Tue Mar 25 09:29:14 2008
@@ -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;
 	}
 
Modified: python/trunk/Objects/codeobject.c
==============================================================================
--- python/trunk/Objects/codeobject.c	(original)
+++ python/trunk/Objects/codeobject.c	Tue Mar 25 09:29:14 2008
@@ -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;
 		}
 
Modified: python/trunk/Objects/dictobject.c
==============================================================================
--- python/trunk/Objects/dictobject.c	(original)
+++ python/trunk/Objects/dictobject.c	Tue Mar 25 09:29:14 2008
@@ -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);
 }
Modified: python/trunk/Objects/exceptions.c
==============================================================================
--- python/trunk/Objects/exceptions.c	(original)
+++ python/trunk/Objects/exceptions.c	Tue Mar 25 09:29:14 2008
@@ -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);
 }
Modified: python/trunk/Objects/listobject.c
==============================================================================
--- python/trunk/Objects/listobject.c	(original)
+++ python/trunk/Objects/listobject.c	Tue Mar 25 09:29:14 2008
@@ -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;
Modified: python/trunk/Objects/methodobject.c
==============================================================================
--- python/trunk/Objects/methodobject.c	(original)
+++ python/trunk/Objects/methodobject.c	Tue Mar 25 09:29:14 2008
@@ -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) {
Modified: python/trunk/Objects/object.c
==============================================================================
--- python/trunk/Objects/object.c	(original)
+++ python/trunk/Objects/object.c	Tue Mar 25 09:29:14 2008
@@ -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;
 			}
Modified: python/trunk/Objects/typeobject.c
==============================================================================
--- python/trunk/Objects/typeobject.c	(original)
+++ python/trunk/Objects/typeobject.c	Tue Mar 25 09:29:14 2008
@@ -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;
 	}
 
Modified: python/trunk/Parser/tokenizer.c
==============================================================================
--- python/trunk/Parser/tokenizer.c	(original)
+++ python/trunk/Parser/tokenizer.c	Tue Mar 25 09:29:14 2008
@@ -1531,7 +1531,7 @@
 #ifndef PGEN
 		if (Py_Py3kWarningFlag && token == NOTEQUAL && c == '<') {
 			if (PyErr_WarnExplicit(PyExc_DeprecationWarning,
-					 "<> not supported in 3.x",
+					 "<> not supported in 3.x; use !=",
 					 tok->filename, tok->lineno,
 					 NULL, NULL)) {
 				return ERRORTOKEN;
Modified: python/trunk/Python/ast.c
==============================================================================
--- python/trunk/Python/ast.c	(original)
+++ python/trunk/Python/ast.c	Tue Mar 25 09:29:14 2008
@@ -1363,7 +1363,7 @@
 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;
Modified: python/trunk/Python/bltinmodule.c
==============================================================================
--- python/trunk/Python/bltinmodule.c	(original)
+++ python/trunk/Python/bltinmodule.c	Tue Mar 25 09:29:14 2008
@@ -166,7 +166,8 @@
 
 	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 @@
 {
 	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 @@
 
 	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 @@
 	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 @@
 
 	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 @@
 {
 	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);
Modified: python/trunk/Python/ceval.c
==============================================================================
--- python/trunk/Python/ceval.c	(original)
+++ python/trunk/Python/ceval.c	Tue Mar 25 09:29:14 2008
@@ -4056,7 +4056,7 @@
 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)
Modified: python/trunk/Python/sysmodule.c
==============================================================================
--- python/trunk/Python/sysmodule.c	(original)
+++ python/trunk/Python/sysmodule.c	Tue Mar 25 09:29:14 2008
@@ -174,8 +174,8 @@
 
 	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();


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /