[Python-checkins] r69641 - in python/branches/io-c/Modules: _bufferedio.c _iobase.c _iomodule.h _textio.c io.c

benjamin.peterson python-checkins at python.org
Sun Feb 15 17:12:37 CET 2009


Author: benjamin.peterson
Date: Sun Feb 15 17:12:37 2009
New Revision: 69641
Log:
make interned strings globals again ;(
putting them in the module state was asking for trouble when the module
was dealloced before the classes in it were
Modified:
 python/branches/io-c/Modules/_bufferedio.c
 python/branches/io-c/Modules/_iobase.c
 python/branches/io-c/Modules/_iomodule.h
 python/branches/io-c/Modules/_textio.c
 python/branches/io-c/Modules/io.c
Modified: python/branches/io-c/Modules/_bufferedio.c
==============================================================================
--- python/branches/io-c/Modules/_bufferedio.c	(original)
+++ python/branches/io-c/Modules/_bufferedio.c	Sun Feb 15 17:12:37 2009
@@ -344,7 +344,6 @@
 {
 PyObject *pos = Py_None;
 PyObject *res;
- _PyIO_State *state = IO_STATE;
 
 CHECK_INITIALIZED(self)
 if (!PyArg_ParseTuple(args, "|O:truncate", &pos)) {
@@ -355,7 +354,7 @@
 * and a flush may be necessary to synch both views of the current
 * file state.
 */
- res = PyObject_CallMethodObjArgs(self->raw, state->str_flush, NULL);
+ res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_flush, NULL);
 if (res == NULL)
 return NULL;
 Py_DECREF(res);
@@ -371,7 +370,7 @@
 /* XXX: Should seek() be used, instead of passing the position
 * XXX directly to truncate?
 */
- res = PyObject_CallMethodObjArgs(self->raw, state->str_truncate, pos, NULL);
+ res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_truncate, pos, NULL);
 Py_DECREF(pos);
 
 return res;
@@ -383,7 +382,7 @@
 BufferedIOMixin_flush(BufferedObject *self, PyObject *args)
 {
 CHECK_INITIALIZED(self)
- return PyObject_CallMethodObjArgs(self->raw, IO_STATE->str_flush, NULL);
+ return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_flush, NULL);
 }
 
 static int
@@ -392,7 +391,7 @@
 int closed;
 PyObject *res;
 CHECK_INITIALIZED_INT(self)
- res = PyObject_GetAttr(self->raw, IO_STATE->str_closed);
+ res = PyObject_GetAttr(self->raw, _PyIO_str_closed);
 if (res == NULL)
 return -1;
 closed = PyObject_IsTrue(res);
@@ -404,7 +403,7 @@
 BufferedIOMixin_closed_get(BufferedObject *self, void *context)
 {
 CHECK_INITIALIZED(self)
- return PyObject_GetAttr(self->raw, IO_STATE->str_closed);
+ return PyObject_GetAttr(self->raw, _PyIO_str_closed);
 }
 
 static PyObject *
@@ -412,7 +411,6 @@
 {
 PyObject *res = NULL;
 int r;
- _PyIO_State *state = IO_STATE;
 
 CHECK_INITIALIZED(self)
 ENTER_BUFFERED(self)
@@ -427,7 +425,7 @@
 }
 /* flush() will most probably re-take the lock, so drop it first */
 LEAVE_BUFFERED(self)
- res = PyObject_CallMethodObjArgs((PyObject *)self, state->str_flush, NULL);
+ res = PyObject_CallMethodObjArgs((PyObject *)self, _PyIO_str_flush, NULL);
 ENTER_BUFFERED(self)
 if (res == NULL) {
 /* If flush() fails, just give up */
@@ -438,7 +436,7 @@
 }
 Py_XDECREF(res);
 
- res = PyObject_CallMethodObjArgs(self->raw, state->str_close, NULL);
+ res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_close, NULL);
 
 end:
 LEAVE_BUFFERED(self)
@@ -451,21 +449,21 @@
 BufferedIOMixin_seekable(BufferedObject *self, PyObject *args)
 {
 CHECK_INITIALIZED(self)
- return PyObject_CallMethodObjArgs(self->raw, IO_STATE->str_seekable, NULL);
+ return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_seekable, NULL);
 }
 
 static PyObject *
 BufferedIOMixin_readable(BufferedObject *self, PyObject *args)
 {
 CHECK_INITIALIZED(self)
- return PyObject_CallMethodObjArgs(self->raw, IO_STATE->str_readable, NULL);
+ return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_readable, NULL);
 }
 
 static PyObject *
 BufferedIOMixin_writable(BufferedObject *self, PyObject *args)
 {
 CHECK_INITIALIZED(self)
- return PyObject_CallMethodObjArgs(self->raw, IO_STATE->str_writable, NULL);
+ return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_writable, NULL);
 }
 
 static PyObject *
@@ -488,14 +486,14 @@
 BufferedIOMixin_fileno(BufferedObject *self, PyObject *args)
 {
 CHECK_INITIALIZED(self)
- return PyObject_CallMethodObjArgs(self->raw, IO_STATE->str_fileno, NULL);
+ return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_fileno, NULL);
 }
 
 static PyObject *
 BufferedIOMixin_isatty(BufferedObject *self, PyObject *args)
 {
 CHECK_INITIALIZED(self)
- return PyObject_CallMethodObjArgs(self->raw, IO_STATE->str_isatty, NULL);
+ return PyObject_CallMethodObjArgs(self->raw, _PyIO_str_isatty, NULL);
 }
 
 
@@ -542,7 +540,7 @@
 {
 PyObject *res;
 Py_off_t n;
- res = PyObject_CallMethodObjArgs(self->raw, IO_STATE->str_tell, NULL);
+ res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_tell, NULL);
 if (res == NULL)
 return -1;
 n = PyNumber_AsOff_t(res, PyExc_ValueError);
@@ -571,7 +569,7 @@
 Py_DECREF(posobj);
 return -1;
 }
- res = PyObject_CallMethodObjArgs(self->raw, IO_STATE->str_seek,
+ res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_seek,
 posobj, whenceobj, NULL);
 Py_DECREF(posobj);
 Py_DECREF(whenceobj);
@@ -1036,7 +1034,7 @@
 }
 _BufferedReader_reset_buf(self);
 }
- res = PyObject_CallMethodObjArgs(self->raw, IO_STATE->str_truncate, pos, NULL);
+ res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_truncate, pos, NULL);
 if (res == NULL)
 goto end;
 /* Reset cached position */
@@ -1064,7 +1062,7 @@
 }
 else {
 line = PyObject_CallMethodObjArgs((PyObject *)self,
- IO_STATE->str_readline, NULL);
+ _PyIO_str_readline, NULL);
 if (line && !PyBytes_Check(line)) {
 PyErr_Format(PyExc_IOError,
 "readline() should have returned a bytes object, "
@@ -1142,7 +1140,7 @@
 memobj = PyMemoryView_FromBuffer(&buf);
 if (memobj == NULL)
 return -1;
- res = PyObject_CallMethodObjArgs(self->raw, IO_STATE->str_readinto, memobj, NULL);
+ res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_readinto, memobj, NULL);
 Py_DECREF(memobj);
 if (res == NULL)
 return -1;
@@ -1187,7 +1185,6 @@
 PyObject *data, *res = NULL;
 Py_ssize_t current_size, remaining, written;
 char *out;
- _PyIO_State *state = IO_STATE;
 static PyObject *sep = NULL;
 
 /* Special case for when the number of bytes to read is unspecified. */
@@ -1228,7 +1225,7 @@
 }
 
 /* Read until EOF or until read() would block. */
- data = PyObject_CallMethodObjArgs(self->raw, state->str_read, NULL);
+ data = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_read, NULL);
 if (data == NULL) {
 Py_DECREF(chunks);
 return NULL;
@@ -1524,7 +1521,7 @@
 memobj = PyMemoryView_FromBuffer(&buf);
 if (memobj == NULL)
 return -1;
- res = PyObject_CallMethodObjArgs(self->raw, IO_STATE->str_write, memobj, NULL);
+ res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_write, memobj, NULL);
 Py_DECREF(memobj);
 if (res == NULL)
 return -1;
Modified: python/branches/io-c/Modules/_iobase.c
==============================================================================
--- python/branches/io-c/Modules/_iobase.c	(original)
+++ python/branches/io-c/Modules/_iobase.c	Sun Feb 15 17:12:37 2009
@@ -134,7 +134,7 @@
 int closed;
 /* This gets the derived attribute, which is *not* __IOBase_closed
 in most cases! */
- res = PyObject_GetAttr(self, IO_STATE->str_closed);
+ res = PyObject_GetAttr(self, _PyIO_str_closed);
 if (res == NULL)
 return 0;
 closed = PyObject_IsTrue(res);
@@ -173,7 +173,7 @@
 if (IS_CLOSED(self))
 Py_RETURN_NONE;
 
- res = PyObject_CallMethodObjArgs(self, IO_STATE->str_flush, NULL);
+ res = PyObject_CallMethodObjArgs(self, _PyIO_str_flush, NULL);
 PyObject_SetAttrString(self, "__IOBase_closed", Py_True);
 if (res == NULL) {
 /* If flush() fails, just give up */
@@ -194,14 +194,13 @@
 PyObject *res;
 PyObject *tp, *v, *tb;
 int closed = 1;
- _PyIO_State *state = IO_STATE;
 PyErr_Fetch(&tp, &v, &tb);
 /* We need to resurrect the object as calling close() can invoke
 arbitrary code. */
 ((PyObject *) self)->ob_refcnt++;
 /* The object could already be in an usable state, so we'll take any
 error as meaning "stop, nothing to see here". */
- res = PyObject_GetAttr(self, state->str_closed);
+ res = PyObject_GetAttr(self, _PyIO_str_closed);
 if (res == NULL)
 PyErr_Clear();
 else {
@@ -211,7 +210,7 @@
 PyErr_Clear();
 }
 if (closed == 0) {
- res = PyObject_CallMethodObjArgs((PyObject *) self, state->str_close,
+ res = PyObject_CallMethodObjArgs((PyObject *) self, _PyIO_str_close,
 NULL);
 if (res == NULL)
 PyErr_Clear();
@@ -248,7 +247,7 @@
 PyObject *
 _PyIOBase_checkSeekable(PyObject *self, PyObject *args)
 {
- PyObject *res = PyObject_CallMethodObjArgs(self, IO_STATE->str_seekable, NULL);
+ PyObject *res = PyObject_CallMethodObjArgs(self, _PyIO_str_seekable, NULL);
 if (res == NULL)
 return NULL;
 if (res != Py_True) {
@@ -277,7 +276,7 @@
 PyObject *
 _PyIOBase_checkReadable(PyObject *self, PyObject *args)
 {
- PyObject *res = PyObject_CallMethodObjArgs(self, IO_STATE->str_readable, NULL);
+ PyObject *res = PyObject_CallMethodObjArgs(self, _PyIO_str_readable, NULL);
 if (res == NULL)
 return NULL;
 if (res != Py_True) {
@@ -306,7 +305,7 @@
 PyObject *
 _PyIOBase_checkWritable(PyObject *self, PyObject *args)
 {
- PyObject *res = PyObject_CallMethodObjArgs(self, IO_STATE->str_writable, NULL);
+ PyObject *res = PyObject_CallMethodObjArgs(self, _PyIO_str_writable, NULL);
 if (res == NULL)
 return NULL;
 if (res != Py_True) {
@@ -335,7 +334,7 @@
 static PyObject *
 IOBase_exit(PyObject *self, PyObject *args)
 {
- return PyObject_CallMethodObjArgs(self, IO_STATE->str_close, NULL);
+ return PyObject_CallMethodObjArgs(self, _PyIO_str_close, NULL);
 }
 
 /* Lower-level APIs */
@@ -485,7 +484,7 @@
 static PyObject *
 IOBase_iternext(PyObject *self)
 {
- PyObject *line = PyObject_CallMethodObjArgs(self, IO_STATE->str_readline, NULL);
+ PyObject *line = PyObject_CallMethodObjArgs(self, _PyIO_str_readline, NULL);
 
 if (line == NULL)
 return NULL;
@@ -562,7 +561,6 @@
 static PyObject *
 IOBase_writelines(PyObject *self, PyObject *args)
 {
- _PyIO_State *state = IO_STATE;
 PyObject *lines, *iter, *res;
 
 if (!PyArg_ParseTuple(args, "O:writelines", &lines)) {
@@ -587,7 +585,7 @@
 break; /* Stop Iteration */
 }
 
- res = PyObject_CallMethodObjArgs(self, state->str_write, line, NULL);
+ res = PyObject_CallMethodObjArgs(self, _PyIO_str_write, line, NULL);
 Py_DECREF(line);
 if (res == NULL) {
 Py_DECREF(iter);
@@ -721,7 +719,7 @@
 if (b == NULL)
 return NULL;
 
- res = PyObject_CallMethodObjArgs(self, IO_STATE->str_readinto, b, NULL);
+ res = PyObject_CallMethodObjArgs(self, _PyIO_str_readinto, b, NULL);
 if (res == NULL) {
 Py_DECREF(b);
 return NULL;
Modified: python/branches/io-c/Modules/_iomodule.h
==============================================================================
--- python/branches/io-c/Modules/_iomodule.h	(original)
+++ python/branches/io-c/Modules/_iomodule.h	Sun Feb 15 17:12:37 2009
@@ -100,31 +100,30 @@
 PyObject *locale_module;
 
 PyObject *unsupported_operation;
-
- /* various interned strings */
- PyObject *str_close;
- PyObject *str_closed;
- PyObject *str_decode;
- PyObject *str_encode;
- PyObject *str_fileno;
- PyObject *str_flush;
- PyObject *str_getstate;
- PyObject *str_isatty;
- PyObject *str_newlines;
- PyObject *str_read;
- PyObject *str_read1;
- PyObject *str_readable;
- PyObject *str_readinto;
- PyObject *str_readline;
- PyObject *str_reset;
- PyObject *str_seek;
- PyObject *str_seekable;
- PyObject *str_tell;
- PyObject *str_truncate;
- PyObject *str_writable;
- PyObject *str_write;
 } _PyIO_State;
 
 
 #define IO_MOD_STATE(mod) ((_PyIO_State *)PyModule_GetState(mod))
 #define IO_STATE IO_MOD_STATE(PyState_FindModule(&_PyIO_Module))
+
+extern PyObject *_PyIO_str_close;
+extern PyObject *_PyIO_str_closed;
+extern PyObject *_PyIO_str_decode;
+extern PyObject *_PyIO_str_encode;
+extern PyObject *_PyIO_str_fileno;
+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_read1;
+extern PyObject *_PyIO_str_readable;
+extern PyObject *_PyIO_str_readinto;
+extern PyObject *_PyIO_str_readline;
+extern PyObject *_PyIO_str_reset;
+extern PyObject *_PyIO_str_seek;
+extern PyObject *_PyIO_str_seekable;
+extern PyObject *_PyIO_str_tell;
+extern PyObject *_PyIO_str_truncate;
+extern PyObject *_PyIO_str_writable;
+extern PyObject *_PyIO_str_write;
Modified: python/branches/io-c/Modules/_textio.c
==============================================================================
--- python/branches/io-c/Modules/_textio.c	(original)
+++ python/branches/io-c/Modules/_textio.c	Sun Feb 15 17:12:37 2009
@@ -226,7 +226,7 @@
 }
 
 /* decode input (with the eventual \r from a previous pass) */
- output = PyObject_CallMethodObjArgs(self->decoder, IO_STATE->str_decode,
+ output = PyObject_CallMethodObjArgs(self->decoder, _PyIO_str_decode,
 input, final ? Py_True : Py_False, NULL);
 if (output == NULL)
 return NULL;
@@ -422,7 +422,7 @@
 IncrementalNewlineDecoder_getstate(PyNewLineDecoderObject *self, PyObject *args)
 {
 PyObject *state = PyObject_CallMethodObjArgs(self->decoder,
- IO_STATE->str_getstate, NULL);
+ _PyIO_str_getstate, NULL);
 PyObject *buffer;
 unsigned PY_LONG_LONG flag;
 
@@ -461,7 +461,7 @@
 {
 self->seennl = 0;
 self->pendingcr = 0;
- return PyObject_CallMethodObjArgs(self->decoder, IO_STATE->str_reset, NULL);
+ return PyObject_CallMethodObjArgs(self->decoder, _PyIO_str_reset, NULL);
 }
 
 static PyObject *
@@ -1046,7 +1046,7 @@
 if (b == NULL)
 return -1;
 ret = PyObject_CallMethodObjArgs(self->buffer,
- IO_STATE->str_write, b, NULL);
+ _PyIO_str_write, b, NULL);
 Py_DECREF(b);
 if (ret == NULL)
 return -1;
@@ -1062,7 +1062,6 @@
 PyObject *ret;
 PyObject *text; /* owned reference */
 PyObject *b;
- _PyIO_State *state = IO_STATE;
 Py_ssize_t textlen;
 int haslf = 0;
 int needflush = 0;
@@ -1104,7 +1103,7 @@
 b = (*self->encodefunc)((PyObject *) self, text);
 else
 b = PyObject_CallMethodObjArgs(self->encoder,
- state->str_encode, text, NULL);
+ _PyIO_str_encode, text, NULL);
 Py_DECREF(text);
 if (b == NULL)
 return NULL;
@@ -1129,7 +1128,7 @@
 }
 
 if (needflush) {
- ret = PyObject_CallMethodObjArgs(self->buffer, state->str_flush, NULL);
+ ret = PyObject_CallMethodObjArgs(self->buffer, _PyIO_str_flush, NULL);
 if (ret == NULL)
 return NULL;
 Py_DECREF(ret);
@@ -1199,7 +1198,6 @@
 PyObject *dec_flags = NULL;
 PyObject *input_chunk = NULL;
 PyObject *decoded_chars, *chunk_size;
- _PyIO_State *iostate = IO_STATE;
 int eof;
 
 /* The return value is True unless EOF was reached. The decoded string is
@@ -1219,7 +1217,7 @@
 */
 
 PyObject *state = PyObject_CallMethodObjArgs(self->decoder,
- iostate->str_getstate, NULL);
+ _PyIO_str_getstate, NULL);
 if (state == NULL)
 return -1;
 /* Given this, we know there was a valid snapshot point
@@ -1239,7 +1237,7 @@
 if (chunk_size == NULL)
 goto fail;
 input_chunk = PyObject_CallMethodObjArgs(self->buffer,
- iostate->str_read1, chunk_size, NULL);
+ _PyIO_str_read1, chunk_size, NULL);
 Py_DECREF(chunk_size);
 if (input_chunk == NULL)
 goto fail;
@@ -1253,7 +1251,7 @@
 }
 else {
 decoded_chars = PyObject_CallMethodObjArgs(self->decoder,
- iostate->str_decode, input_chunk, eof ? Py_True : Py_False, NULL);
+ _PyIO_str_decode, input_chunk, eof ? Py_True : Py_False, NULL);
 }
 
 /* TODO sanity check: isinstance(decoded_chars, unicode) */
@@ -1308,7 +1306,7 @@
 PyObject *decoded;
 if (bytes == NULL)
 goto fail;
- decoded = PyObject_CallMethodObjArgs(self->decoder, IO_STATE->str_decode,
+ decoded = PyObject_CallMethodObjArgs(self->decoder, _PyIO_str_decode,
 bytes, Py_True, NULL);
 Py_DECREF(bytes);
 if (decoded == NULL)
@@ -1748,7 +1746,7 @@
 utf-16, that we are expecting a BOM).
 */
 if (cookie->start_pos == 0 && cookie->dec_flags == 0)
- res = PyObject_CallMethodObjArgs(self->decoder, IO_STATE->str_reset, NULL);
+ res = PyObject_CallMethodObjArgs(self->decoder, _PyIO_str_reset, NULL);
 else
 res = PyObject_CallMethod(self->decoder, "setstate",
 "((yi))", "", cookie->dec_flags);
@@ -1766,7 +1764,6 @@
 int whence = 0;
 static PyObject *zero = NULL;
 PyObject *res;
- _PyIO_State *state = IO_STATE;
 int cmp;
 
 CHECK_INITIALIZED(self);
@@ -1855,7 +1852,7 @@
 goto fail;
 }
 
- res = PyObject_CallMethodObjArgs((PyObject *)self, state->str_flush, NULL);
+ res = PyObject_CallMethodObjArgs((PyObject *)self, _PyIO_str_flush, NULL);
 if (res == NULL)
 goto fail;
 Py_DECREF(res);
@@ -1871,7 +1868,7 @@
 if (posobj == NULL)
 goto fail;
 res = PyObject_CallMethodObjArgs(self->buffer,
- state->str_seek, posobj, NULL);
+ _PyIO_str_seek, posobj, NULL);
 Py_DECREF(posobj);
 if (res == NULL)
 goto fail;
@@ -1939,7 +1936,6 @@
 Py_ssize_t chars_to_skip, chars_decoded;
 PyObject *saved_state = NULL;
 char *input, *input_end;
- _PyIO_State *iostate = IO_STATE;
 
 CHECK_INITIALIZED(self);
 CHECK_CLOSED(self);
@@ -2000,7 +1996,7 @@
 * forward until it gives us enough decoded characters.
 */
 saved_state = PyObject_CallMethodObjArgs(self->decoder,
- iostate->str_getstate, NULL);
+ _PyIO_str_getstate, NULL);
 if (saved_state == NULL)
 goto fail;
 
@@ -2033,7 +2029,7 @@
 cookie.bytes_to_feed += 1;
 
 state = PyObject_CallMethodObjArgs(self->decoder,
- iostate->str_getstate, NULL);
+ _PyIO_str_getstate, NULL);
 if (state == NULL)
 goto fail;
 if (!PyArg_Parse(state, "(y#i)", &dec_buffer, &dec_buffer_len, &dec_flags)) {
@@ -2105,27 +2101,26 @@
 {
 PyObject *pos = Py_None;
 PyObject *res;
- _PyIO_State *state = IO_STATE;
 
 CHECK_INITIALIZED(self)
 if (!PyArg_ParseTuple(args, "|O:truncate", &pos)) {
 return NULL;
 }
 
- res = PyObject_CallMethodObjArgs((PyObject *) self, state->str_flush, NULL);
+ res = PyObject_CallMethodObjArgs((PyObject *) self, _PyIO_str_flush, NULL);
 if (res == NULL)
 return NULL;
 Py_DECREF(res);
 
 if (pos != Py_None) {
 res = PyObject_CallMethodObjArgs((PyObject *) self,
- state->str_seek, pos, NULL);
+ _PyIO_str_seek, pos, NULL);
 if (res == NULL)
 return NULL;
 Py_DECREF(res);
 }
 
- return PyObject_CallMethodObjArgs(self->buffer, state->str_truncate, NULL);
+ return PyObject_CallMethodObjArgs(self->buffer, _PyIO_str_truncate, NULL);
 }
 
 /* Inquiries */
@@ -2206,7 +2201,7 @@
 }
 else {
 line = PyObject_CallMethodObjArgs((PyObject *)self,
- IO_STATE->str_readline, NULL);
+ _PyIO_str_readline, NULL);
 if (line && !PyUnicode_Check(line)) {
 PyErr_Format(PyExc_IOError,
 "readline() should have returned an str object, "
@@ -2241,7 +2236,7 @@
 TextIOWrapper_closed_get(PyTextIOWrapperObject *self, void *context)
 {
 CHECK_INITIALIZED(self);
- return PyObject_GetAttr(self->buffer, IO_STATE->str_closed);
+ return PyObject_GetAttr(self->buffer, _PyIO_str_closed);
 }
 
 static PyObject *
@@ -2251,7 +2246,7 @@
 CHECK_INITIALIZED(self);
 if (self->decoder == NULL)
 Py_RETURN_NONE;
- res = PyObject_GetAttr(self->decoder, IO_STATE->str_newlines);
+ res = PyObject_GetAttr(self->decoder, _PyIO_str_newlines);
 if (res == NULL) {
 PyErr_Clear();
 Py_RETURN_NONE;
Modified: python/branches/io-c/Modules/io.c
==============================================================================
--- python/branches/io-c/Modules/io.c	(original)
+++ python/branches/io-c/Modules/io.c	Sun Feb 15 17:12:37 2009
@@ -21,6 +21,30 @@
 #endif /* HAVE_SYS_STAT_H */
 
 
+/* Various interned strings */
+
+PyObject *_PyIO_str_close;
+PyObject *_PyIO_str_closed;
+PyObject *_PyIO_str_decode;
+PyObject *_PyIO_str_encode;
+PyObject *_PyIO_str_fileno;
+PyObject *_PyIO_str_flush;
+PyObject *_PyIO_str_getstate;
+PyObject *_PyIO_str_isatty;
+PyObject *_PyIO_str_newlines;
+PyObject *_PyIO_str_read;
+PyObject *_PyIO_str_read1;
+PyObject *_PyIO_str_readable;
+PyObject *_PyIO_str_readinto;
+PyObject *_PyIO_str_readline;
+PyObject *_PyIO_str_reset;
+PyObject *_PyIO_str_seek;
+PyObject *_PyIO_str_seekable;
+PyObject *_PyIO_str_tell;
+PyObject *_PyIO_str_truncate;
+PyObject *_PyIO_str_writable;
+PyObject *_PyIO_str_write;
+
 
 PyDoc_STRVAR(module_doc,
 "The io module provides the Python interfaces to stream handling. The\n"
@@ -549,30 +573,8 @@
 }
 
 static void
-iomodule_free(_PyIO_State *state) {
- iomodule_clear(state);
-
- Py_DECREF(state->str_close);
- Py_DECREF(state->str_closed);
- Py_DECREF(state->str_decode);
- Py_DECREF(state->str_encode);
- Py_DECREF(state->str_fileno);
- Py_DECREF(state->str_flush);
- Py_DECREF(state->str_getstate);
- Py_DECREF(state->str_isatty);
- Py_DECREF(state->str_newlines);
- Py_DECREF(state->str_read);
- Py_DECREF(state->str_read1);
- Py_DECREF(state->str_readable);
- Py_DECREF(state->str_readinto);
- Py_DECREF(state->str_readline);
- Py_DECREF(state->str_reset);
- Py_DECREF(state->str_seek);
- Py_DECREF(state->str_seekable);
- Py_DECREF(state->str_tell);
- Py_DECREF(state->str_truncate);
- Py_DECREF(state->str_writable);
- Py_DECREF(state->str_write);
+iomodule_free(_PyIO_State *mod) {
+ iomodule_clear(mod);
 }
 
 /*
@@ -710,47 +712,47 @@
 PyModule_AddObject(m, "IncrementalNewlineDecoder", (PyObject *) &PyIncrementalNewlineDecoder_Type);
 
 /* Interned strings */
- if (!(state->str_close = PyUnicode_InternFromString("close")))
+ if (!(_PyIO_str_close = PyUnicode_InternFromString("close")))
 goto fail;
- if (!(state->str_closed = PyUnicode_InternFromString("closed")))
+ if (!(_PyIO_str_closed = PyUnicode_InternFromString("closed")))
 goto fail;
- if (!(state->str_decode = PyUnicode_InternFromString("decode")))
+ if (!(_PyIO_str_decode = PyUnicode_InternFromString("decode")))
 goto fail;
- if (!(state->str_encode = PyUnicode_InternFromString("encode")))
+ if (!(_PyIO_str_encode = PyUnicode_InternFromString("encode")))
 goto fail;
- if (!(state->str_fileno = PyUnicode_InternFromString("fileno")))
+ if (!(_PyIO_str_fileno = PyUnicode_InternFromString("fileno")))
 goto fail;
- if (!(state->str_flush = PyUnicode_InternFromString("flush")))
+ if (!(_PyIO_str_flush = PyUnicode_InternFromString("flush")))
 goto fail;
- if (!(state->str_getstate = PyUnicode_InternFromString("getstate")))
+ if (!(_PyIO_str_getstate = PyUnicode_InternFromString("getstate")))
 goto fail;
- if (!(state->str_isatty = PyUnicode_InternFromString("isatty")))
+ if (!(_PyIO_str_isatty = PyUnicode_InternFromString("isatty")))
 goto fail;
- if (!(state->str_newlines = PyUnicode_InternFromString("newlines")))
+ if (!(_PyIO_str_newlines = PyUnicode_InternFromString("newlines")))
 goto fail;
- if (!(state->str_read = PyUnicode_InternFromString("read")))
+ if (!(_PyIO_str_read = PyUnicode_InternFromString("read")))
 goto fail;
- if (!(state->str_read1 = PyUnicode_InternFromString("read1")))
+ if (!(_PyIO_str_read1 = PyUnicode_InternFromString("read1")))
 goto fail;
- if (!(state->str_readable = PyUnicode_InternFromString("readable")))
+ if (!(_PyIO_str_readable = PyUnicode_InternFromString("readable")))
 goto fail;
- if (!(state->str_readinto = PyUnicode_InternFromString("readinto")))
+ if (!(_PyIO_str_readinto = PyUnicode_InternFromString("readinto")))
 goto fail;
- if (!(state->str_readline = PyUnicode_InternFromString("readline")))
+ if (!(_PyIO_str_readline = PyUnicode_InternFromString("readline")))
 goto fail;
- if (!(state->str_reset = PyUnicode_InternFromString("reset")))
+ if (!(_PyIO_str_reset = PyUnicode_InternFromString("reset")))
 goto fail;
- if (!(state->str_seek = PyUnicode_InternFromString("seek")))
+ if (!(_PyIO_str_seek = PyUnicode_InternFromString("seek")))
 goto fail;
- if (!(state->str_seekable = PyUnicode_InternFromString("seekable")))
+ if (!(_PyIO_str_seekable = PyUnicode_InternFromString("seekable")))
 goto fail;
- if (!(state->str_tell = PyUnicode_InternFromString("tell")))
+ if (!(_PyIO_str_tell = PyUnicode_InternFromString("tell")))
 goto fail;
- if (!(state->str_truncate = PyUnicode_InternFromString("truncate")))
+ if (!(_PyIO_str_truncate = PyUnicode_InternFromString("truncate")))
 goto fail;
- if (!(state->str_write = PyUnicode_InternFromString("write")))
+ if (!(_PyIO_str_write = PyUnicode_InternFromString("write")))
 goto fail;
- if (!(state->str_writable = PyUnicode_InternFromString("writable")))
+ if (!(_PyIO_str_writable = PyUnicode_InternFromString("writable")))
 goto fail;
 
 return m;


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /