[Python-checkins] r69815 - in python/branches/io-c: Lib/test/test_io.py Modules/_textio.c
antoine.pitrou
python-checkins at python.org
Fri Feb 20 21:13:12 CET 2009
Author: antoine.pitrou
Date: Fri Feb 20 21:13:11 2009
New Revision: 69815
Log:
Add the line_buffering property to TextIOWrapper, and test for it
Modified:
python/branches/io-c/Lib/test/test_io.py
python/branches/io-c/Modules/_textio.c
Modified: python/branches/io-c/Lib/test/test_io.py
==============================================================================
--- python/branches/io-c/Lib/test/test_io.py (original)
+++ python/branches/io-c/Lib/test/test_io.py Fri Feb 20 21:13:11 2009
@@ -1255,7 +1255,11 @@
b = io.BufferedReader(r, 1000)
t = io.TextIOWrapper(b)
t.__init__(b, encoding="latin1", newline="\r\n")
- t.__init__(b, encoding="utf8")
+ self.assertEquals(t.encoding, "latin1")
+ self.assertEquals(t.line_buffering, False)
+ t.__init__(b, encoding="utf8", line_buffering=True)
+ self.assertEquals(t.encoding, "utf8")
+ self.assertEquals(t.line_buffering, True)
self.assertEquals("\xe9\n", t.readline())
self.assertRaises(TypeError, t.__init__, b, newline=42)
self.assertRaises(ValueError, t.read)
Modified: python/branches/io-c/Modules/_textio.c
==============================================================================
--- python/branches/io-c/Modules/_textio.c (original)
+++ python/branches/io-c/Modules/_textio.c Fri Feb 20 21:13:11 2009
@@ -584,12 +584,12 @@
PyObject *readnl;
PyObject *errors;
const char *writenl; /* utf-8 encoded, NULL stands for \n */
- int line_buffering:1;
- int readuniversal:1;
- int readtranslate:1;
- int writetranslate:1;
- int seekable:1;
- int telling:1;
+ char line_buffering;
+ char readuniversal;
+ char readtranslate;
+ char writetranslate;
+ char seekable;
+ char telling;
/* Specialized encoding func (see below) */
encodefunc_t encodefunc;
@@ -2312,6 +2312,7 @@
static PyMemberDef TextIOWrapper_members[] = {
{"encoding", T_OBJECT, offsetof(PyTextIOWrapperObject, encoding), READONLY},
{"buffer", T_OBJECT, offsetof(PyTextIOWrapperObject, buffer), READONLY},
+ {"line_buffering", T_BOOL, offsetof(PyTextIOWrapperObject, line_buffering), READONLY},
{NULL}
};
More information about the Python-checkins
mailing list