[Python-checkins] r68387 - in sandbox/trunk/io-c: _iomodule.h _textio.c io.c

antoine.pitrou python-checkins at python.org
Thu Jan 8 01:13:39 CET 2009


Author: antoine.pitrou
Date: Thu Jan  8 01:13:39 2009
New Revision: 68387

Log:
Add a newlines attribute to TextIOWrapper, so that test_univnewlines isn't skipped
(but then there are some failures)



Modified:
   sandbox/trunk/io-c/_iomodule.h
   sandbox/trunk/io-c/_textio.c
   sandbox/trunk/io-c/io.c

Modified: sandbox/trunk/io-c/_iomodule.h
==============================================================================
--- sandbox/trunk/io-c/_iomodule.h	(original)
+++ sandbox/trunk/io-c/_iomodule.h	Thu Jan  8 01:13:39 2009
@@ -58,6 +58,7 @@
 extern PyObject *_PyIO_str_flush;
 extern PyObject *_PyIO_str_getstate;
 extern PyObject *_PyIO_str_isatty;
+extern PyObject *_PyIO_str_newlines;
 extern PyObject *_PyIO_str_read;
 extern PyObject *_PyIO_str_readable;
 extern PyObject *_PyIO_str_readinto;

Modified: sandbox/trunk/io-c/_textio.c
==============================================================================
--- sandbox/trunk/io-c/_textio.c	(original)
+++ sandbox/trunk/io-c/_textio.c	Thu Jan  8 01:13:39 2009
@@ -1564,7 +1564,21 @@
 static PyObject *
 TextIOWrapper_closed_get(PyTextIOWrapperObject *self, void *context)
 {
-    return PyObject_GetAttrString(self->buffer, "closed");
+    return PyObject_GetAttr(self->buffer, _PyIO_str_closed);
+}
+
+static PyObject *
+TextIOWrapper_newlines_get(PyTextIOWrapperObject *self, void *context)
+{
+    PyObject *res;
+    if (self->decoder == NULL)
+        Py_RETURN_NONE;
+    res = PyObject_GetAttr(self->decoder, _PyIO_str_newlines);
+    if (res == NULL) {
+        PyErr_Clear();
+        Py_RETURN_NONE;
+    }
+    return res;
 }
 
 static PyMethodDef TextIOWrapper_methods[] = {
@@ -1601,6 +1615,7 @@
     {"closed", (getter)TextIOWrapper_closed_get, NULL, NULL},
 /*    {"mode", (getter)TextIOWrapper_mode_get, NULL, NULL},
 */
+    {"newlines", (getter)TextIOWrapper_newlines_get, NULL, NULL},
     {0}
 };
 

Modified: sandbox/trunk/io-c/io.c
==============================================================================
--- sandbox/trunk/io-c/io.c	(original)
+++ sandbox/trunk/io-c/io.c	Thu Jan  8 01:13:39 2009
@@ -22,6 +22,7 @@
 PyObject *_PyIO_str_flush;
 PyObject *_PyIO_str_getstate;
 PyObject *_PyIO_str_isatty;
+PyObject *_PyIO_str_newlines;
 PyObject *_PyIO_str_read;
 PyObject *_PyIO_str_readable;
 PyObject *_PyIO_str_readinto;
@@ -644,6 +645,8 @@
         goto fail;
     if (!(_PyIO_str_isatty = PyUnicode_InternFromString("isatty")))
         goto fail;
+    if (!(_PyIO_str_newlines = PyUnicode_InternFromString("newlines")))
+        goto fail;
     if (!(_PyIO_str_read = PyUnicode_InternFromString("read")))
         goto fail;
     if (!(_PyIO_str_readable = PyUnicode_InternFromString("readable")))


More information about the Python-checkins mailing list