Mark xreadlines deprecated. Don't use f.xreadlines() in test_iter.py.

This commit is contained in:
Guido van Rossum 2002-08-06 17:14:04 +00:00
parent 97c5fccd77
commit 8ee5243434
3 changed files with 7 additions and 2 deletions

View File

@ -269,7 +269,7 @@ def test_builtin_list(self):
try:
self.assertEqual(list(f), ["0\n", "1\n", "2\n", "3\n", "4\n"])
f.seek(0, 0)
self.assertEqual(list(f.xreadlines()),
self.assertEqual(list(f),
["0\n", "1\n", "2\n", "3\n", "4\n"])
finally:
f.close()
@ -302,7 +302,7 @@ def test_builtin_tuple(self):
try:
self.assertEqual(tuple(f), ("0\n", "1\n", "2\n", "3\n", "4\n"))
f.seek(0, 0)
self.assertEqual(tuple(f.xreadlines()),
self.assertEqual(tuple(f),
("0\n", "1\n", "2\n", "3\n", "4\n"))
finally:
f.close()

View File

@ -1,5 +1,8 @@
from test.test_support import verbose
import warnings
warnings.filterwarnings('ignore', "xreadlines", DeprecationWarning)
class XReader:
def __init__(self):
self.count = 5

View File

@ -173,4 +173,6 @@ initxreadlines(void)
{
XReadlinesObject_Type.ob_type = &PyType_Type;
Py_InitModule("xreadlines", xreadlines_functions);
PyErr_Warn(PyExc_DeprecationWarning,
"xreadlines is deprecated; use 'for line in file'.");
}