[Python-3000-checkins] r55191 - in python/branches/py3k-struni/Lib: io.py test/test_io.py

guido.van.rossum python-3000-checkins at python.org
Tue May 8 22:18:44 CEST 2007


Author: guido.van.rossum
Date: Tue May  8 22:18:39 2007
New Revision: 55191

Modified:
   python/branches/py3k-struni/Lib/io.py
   python/branches/py3k-struni/Lib/test/test_io.py
Log:
Fix a few places where a str instead of a bytes object was used.


Modified: python/branches/py3k-struni/Lib/io.py
==============================================================================
--- python/branches/py3k-struni/Lib/io.py	(original)
+++ python/branches/py3k-struni/Lib/io.py	Tue May  8 22:18:39 2007
@@ -1047,7 +1047,7 @@
             return self._encode_decoder_state(decoder_state, position)
         saved_state = decoder.getstate()
         try:
-            decoder.setstate(("", decoder_state))
+            decoder.setstate((b"", decoder_state))
             n = 0
             bb = bytes(1)
             for i, bb[0] in enumerate(readahead):

Modified: python/branches/py3k-struni/Lib/test/test_io.py
==============================================================================
--- python/branches/py3k-struni/Lib/test/test_io.py	(original)
+++ python/branches/py3k-struni/Lib/test/test_io.py	Tue May  8 22:18:39 2007
@@ -87,9 +87,9 @@
         self.assertEqual(f.tell(), 6)
         self.assertEqual(f.seek(-1, 1), 5)
         self.assertEqual(f.tell(), 5)
-        self.assertEqual(f.write(" world\n\n\n"), 9)
+        self.assertEqual(f.write(str8(" world\n\n\n")), 9)
         self.assertEqual(f.seek(0), 0)
-        self.assertEqual(f.write("h"), 1)
+        self.assertEqual(f.write(b"h"), 1)
         self.assertEqual(f.seek(-1, 2), 13)
         self.assertEqual(f.tell(), 13)
         self.assertEqual(f.truncate(12), 12)
@@ -230,7 +230,7 @@
 
     def test_close_flushes(self):
         f = io.open(test_support.TESTFN, "wb")
-        f.write("xxx")
+        f.write(b"xxx")
         f.close()
         f = io.open(test_support.TESTFN, "rb")
         self.assertEqual(f.read(), b"xxx")
@@ -595,7 +595,7 @@
         f.close()
         f = io.open(test_support.TESTFN, "r", encoding="utf-8")
         s = f.read(prefix_size)
-        self.assertEquals(s, prefix)
+        self.assertEquals(s, str(prefix))
         self.assertEquals(f.tell(), prefix_size)
         self.assertEquals(f.readline(), u_suffix)
 


More information about the Python-3000-checkins mailing list