Support name and mode attributes on all file types.

Don't read more than one line when reading text from a tty device.
Add peek() and read1() methods.
Return str instead of unicode when return ASCII characters in text mode.
This commit is contained in:
Guido van Rossum 2007-04-13 18:42:35 +00:00
parent 913dd0be52
commit 13633bb8c5
3 changed files with 83 additions and 18 deletions

View file

@ -163,14 +163,7 @@ class BytesTest(unittest.TestCase):
f.write(b)
with open(tfn, "rb") as f:
self.assertEqual(f.read(), sample)
# Test writing in text mode
with open(tfn, "w") as f:
f.write(b)
with open(tfn, "r") as f:
self.assertEqual(f.read(), sample)
# Can't use readinto in text mode
with open(tfn, "r") as f:
self.assertRaises(TypeError, f.readinto, b)
# Text mode is ambiguous; don't test
finally:
try:
os.remove(tfn)