[Python-checkins] r67326 - in python/trunk: Lib/test/test_fileio.py Lib/test/test_io.py Misc/NEWS Modules/_fileio.c
benjamin.peterson
python-checkins at python.org
Sat Nov 22 02:59:15 CET 2008
Author: benjamin.peterson
Date: Sat Nov 22 02:59:15 2008
New Revision: 67326
Log:
backport r67325: make FileIO.mode always contain 'b'
Modified:
python/trunk/Lib/test/test_fileio.py
python/trunk/Lib/test/test_io.py
python/trunk/Misc/NEWS
python/trunk/Modules/_fileio.c
Modified: python/trunk/Lib/test/test_fileio.py
==============================================================================
--- python/trunk/Lib/test/test_fileio.py (original)
+++ python/trunk/Lib/test/test_fileio.py Sat Nov 22 02:59:15 2008
@@ -50,7 +50,7 @@
# verify expected attributes exist
f = self.f
- self.assertEquals(f.mode, "w")
+ self.assertEquals(f.mode, "wb")
self.assertEquals(f.closed, False)
# verify the attributes are readonly
@@ -160,7 +160,7 @@
def testModeStrings(self):
# check invalid mode strings
- for mode in ("", "aU", "wU+", "rb", "rt"):
+ for mode in ("", "aU", "wU+", "rw", "rt"):
try:
f = _fileio._FileIO(TESTFN, mode)
except ValueError:
Modified: python/trunk/Lib/test/test_io.py
==============================================================================
--- python/trunk/Lib/test/test_io.py (original)
+++ python/trunk/Lib/test/test_io.py Sat Nov 22 02:59:15 2008
@@ -1266,7 +1266,7 @@
def test_attributes(self):
f = io.open(test_support.TESTFN, "wb", buffering=0)
- self.assertEquals(f.mode, "w")
+ self.assertEquals(f.mode, "wb")
f.close()
f = io.open(test_support.TESTFN, "U")
@@ -1274,18 +1274,18 @@
self.assertEquals(f.buffer.name, test_support.TESTFN)
self.assertEquals(f.buffer.raw.name, test_support.TESTFN)
self.assertEquals(f.mode, "U")
- self.assertEquals(f.buffer.mode, "r")
- self.assertEquals(f.buffer.raw.mode, "r")
+ self.assertEquals(f.buffer.mode, "rb")
+ self.assertEquals(f.buffer.raw.mode, "rb")
f.close()
f = io.open(test_support.TESTFN, "w+")
self.assertEquals(f.mode, "w+")
- self.assertEquals(f.buffer.mode, "r+") # Does it really matter?
- self.assertEquals(f.buffer.raw.mode, "r+")
+ self.assertEquals(f.buffer.mode, "rb+") # Does it really matter?
+ self.assertEquals(f.buffer.raw.mode, "rb+")
g = io.open(f.fileno(), "wb", closefd=False)
- self.assertEquals(g.mode, "w")
- self.assertEquals(g.raw.mode, "w")
+ self.assertEquals(g.mode, "wb")
+ self.assertEquals(g.raw.mode, "wb")
self.assertEquals(g.name, f.fileno())
self.assertEquals(g.raw.name, f.fileno())
f.close()
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Sat Nov 22 02:59:15 2008
@@ -56,6 +56,8 @@
- Issue #4363: The uuid.uuid1() and uuid.uuid4() functions now work even if
the ctypes module is not present.
+- FileIO's mode attribute now always includes ``"b"``.
+
- Issue #4116: Resolve member name conflict in ScrolledCanvas.__init__.
- httplib.HTTPConnection.putheader() now accepts an arbitrary number of values
Modified: python/trunk/Modules/_fileio.c
==============================================================================
--- python/trunk/Modules/_fileio.c (original)
+++ python/trunk/Modules/_fileio.c Sat Nov 22 02:59:15 2008
@@ -208,6 +208,8 @@
flags |= O_CREAT;
append = 1;
break;
+ case 'b':
+ break;
case '+':
if (plus)
goto bad_mode;
@@ -682,12 +684,12 @@
{
if (self->readable) {
if (self->writable)
- return "r+";
+ return "rb+";
else
- return "r";
+ return "rb";
}
else
- return "w";
+ return "wb";
}
static PyObject *
More information about the Python-checkins
mailing list