[Python-checkins] r61881 - in python/trunk: Misc/NEWS Modules/arraymodule.c

georg.brandl python-checkins at python.org
Tue Mar 25 09:37:23 CET 2008


Author: georg.brandl
Date: Tue Mar 25 09:37:23 2008
New Revision: 61881

Modified:
   python/trunk/Misc/NEWS
   python/trunk/Modules/arraymodule.c
Log:
#2359: add Py3k warning for array.read/array.write.


Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Tue Mar 25 09:37:23 2008
@@ -48,6 +48,8 @@
   are still valid. There are binary literals with a prefix of "0b".
   This also affects int(x, 0).
 
+- Issue #2359: Adding deprecation warnings for array.{read,write}.
+
 - Issue #1779871: Gnu gcc can now build Python on OS X because the
   flags -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd are no
   longer passed.

Modified: python/trunk/Modules/arraymodule.c
==============================================================================
--- python/trunk/Modules/arraymodule.c	(original)
+++ python/trunk/Modules/arraymodule.c	Tue Mar 25 09:37:23 2008
@@ -1255,6 +1255,18 @@
 
 
 static PyObject *
+array_fromfile_as_read(arrayobject *self, PyObject *args)
+{
+	if (Py_Py3kWarningFlag &&
+	    PyErr_Warn(PyExc_DeprecationWarning,
+		       "array.read() not supported in 3.x; "
+		       "use array.fromfile()") < 0)
+		return NULL;
+	return array_fromfile(self, args);
+}
+
+
+static PyObject *
 array_tofile(arrayobject *self, PyObject *f)
 {
 	FILE *fp;
@@ -1284,6 +1296,18 @@
 
 
 static PyObject *
+array_tofile_as_write(arrayobject *self, PyObject *f)
+{
+	if (Py_Py3kWarningFlag &&
+	    PyErr_Warn(PyExc_DeprecationWarning,
+		       "array.write() not supported in 3.x; "
+		       "use array.tofile()") < 0)
+		return NULL;
+	return array_tofile(self, f);
+}
+
+
+static PyObject *
 array_fromlist(arrayobject *self, PyObject *list)
 {
 	Py_ssize_t n;
@@ -1522,7 +1546,7 @@
 	 insert_doc},
 	{"pop",		(PyCFunction)array_pop,		METH_VARARGS,
 	 pop_doc},
-	{"read",	(PyCFunction)array_fromfile,	METH_VARARGS,
+	{"read",	(PyCFunction)array_fromfile_as_read,	METH_VARARGS,
 	 fromfile_doc},
 	{"__reduce__",	(PyCFunction)array_reduce,	METH_NOARGS,
 	 array_doc},
@@ -1542,7 +1566,7 @@
 	{"tounicode",   (PyCFunction)array_tounicode,	METH_NOARGS,
 	 tounicode_doc},
 #endif
-	{"write",	(PyCFunction)array_tofile,	METH_O,
+	{"write",	(PyCFunction)array_tofile_as_write,	METH_O,
 	 tofile_doc},
 	{NULL,		NULL}		/* sentinel */
 };


More information about the Python-checkins mailing list