[Python-checkins] r55814 - python/branches/cpy_merge/Modules/_bytes_iomodule.c python/branches/cpy_merge/Modules/_string_iomodule.c
alexandre.vassalotti
python-checkins at python.org
Thu Jun 7 23:51:26 CEST 2007
Author: alexandre.vassalotti
Date: Thu Jun 7 23:51:21 2007
New Revision: 55814
Modified:
python/branches/cpy_merge/Modules/_bytes_iomodule.c
python/branches/cpy_merge/Modules/_string_iomodule.c
Log:
Update to reflect the new IO API.
Modified: python/branches/cpy_merge/Modules/_bytes_iomodule.c
==============================================================================
--- python/branches/cpy_merge/Modules/_bytes_iomodule.c (original)
+++ python/branches/cpy_merge/Modules/_bytes_iomodule.c Thu Jun 7 23:51:21 2007
@@ -113,6 +113,13 @@
return result;
}
+/* Generic getter for the writable, readable and seekable properties */
+static PyObject *
+bytes_io_get_true(BytesIOObject *self)
+{
+ Py_RETURN_TRUE;
+}
+
static PyObject *
bytes_io_flush(BytesIOObject *self)
{
@@ -323,7 +330,7 @@
while (--position >= self->string_size)
self->buf[position] = 0;
- Py_RETURN_NONE;
+ return Py_BuildValue("n", self->pos);
}
static PyObject *
@@ -492,12 +499,13 @@
"close() -> None. Close the file and release the resources held.");
PyDoc_STRVAR(BytesIO_seek_doc,
-"seek(offset[, whence]) -> None. Set the file's current position.\n"
+"seek(pos, whence=0) -> int. Change stream position.\n"
"\n"
-"Argument offset is a byte count. Optional argument whence defaults to\n"
-"0 (offset from start of file, offset should be >= 0); other values are 1\n"
-"(move relative to current position, positive or negative), and 2 (move\n"
-"relative to end of file, usually negative).\n");
+"Seek to byte offset pos relative to position indicated by whence:\n"
+" 0 Start of stream (the default). pos should be >= 0;\n"
+" 1 Current position - whence may be negative;\n"
+" 2 End of stream - whence usually negative.\n"
+"Returns the new absolute position.");
PyDoc_STRVAR(BytesIO_write_doc,
"write(str) -> None. Write string str to file.");
@@ -510,8 +518,14 @@
static PyGetSetDef BytesIO_getsetlist[] = {
- {"closed", (getter) bytes_io_get_closed, NULL,
- "True if the file is closed"},
+ {"closed", (getter) bytes_io_get_closed, NULL,
+ "True if the file is closed."},
+ {"writeable", (getter) bytes_io_get_true, NULL,
+ "Always True."},
+ {"readable", (getter) bytes_io_get_true, NULL,
+ "Always True."},
+ {"seekable", (getter) bytes_io_get_true, NULL,
+ "Always True."},
{0}, /* sentinel */
};
Modified: python/branches/cpy_merge/Modules/_string_iomodule.c
==============================================================================
--- python/branches/cpy_merge/Modules/_string_iomodule.c (original)
+++ python/branches/cpy_merge/Modules/_string_iomodule.c Thu Jun 7 23:51:21 2007
@@ -116,6 +116,13 @@
return result;
}
+/* Generic getter for the writable, readable and seekable properties */
+static PyObject *
+string_io_get_true(StringIOObject *self)
+{
+ Py_RETURN_TRUE;
+}
+
static PyObject *
string_io_flush(StringIOObject *self)
{
@@ -326,7 +333,7 @@
while (--position >= self->string_size)
self->buf[position] = 0;
- Py_RETURN_NONE;
+ return Py_BuildValue("n", self->pos);
}
static PyObject *
@@ -502,12 +509,13 @@
"close() -> None. Close the file and release the resources held.");
PyDoc_STRVAR(StringIO_seek_doc,
-"seek(offset[, whence]) -> None. Set the file's current position.\n"
+"seek(pos, whence=0) -> int. Change stream position.\n"
"\n"
-"Argument offset is a byte count. Optional argument whence defaults to\n"
-"0 (offset from start of file, offset should be >= 0); other values are 1\n"
-"(move relative to current position, positive or negative), and 2 (move\n"
-"relative to end of file, usually negative).\n");
+"Seek to byte offset pos relative to position indicated by whence:\n"
+" 0 Start of stream (the default). pos should be >= 0;\n"
+" 1 Current position - whence may be negative;\n"
+" 2 End of stream - whence usually negative.\n"
+"Returns the new absolute position.");
PyDoc_STRVAR(StringIO_write_doc,
"write(str) -> None. Write string str to file.");
@@ -522,6 +530,12 @@
static PyGetSetDef StringIO_getsetlist[] = {
{"closed", (getter) string_io_get_closed, NULL,
"True if the file is closed"},
+ {"writeable", (getter) string_io_get_true, NULL,
+ "Always True."},
+ {"readable", (getter) string_io_get_true, NULL,
+ "Always True."},
+ {"seekable", (getter) string_io_get_true, NULL,
+ "Always True."},
{0}, /* sentinel */
};
More information about the Python-checkins
mailing list