Commit fc1b6f00 authored by Antoine Pitrou's avatar Antoine Pitrou

Fix the _io module leaking references when a sub-interpreter is created.

parent 1c7ade52
...@@ -741,58 +741,46 @@ PyInit__io(void) ...@@ -741,58 +741,46 @@ PyInit__io(void)
ADD_TYPE(&PyIncrementalNewlineDecoder_Type, "IncrementalNewlineDecoder"); ADD_TYPE(&PyIncrementalNewlineDecoder_Type, "IncrementalNewlineDecoder");
/* Interned strings */ /* Interned strings */
if (!(_PyIO_str_close = PyUnicode_InternFromString("close"))) #define ADD_INTERNED(name) \
if (!_PyIO_str_ ## name && \
!(_PyIO_str_ ## name = PyUnicode_InternFromString(# name))) \
goto fail; goto fail;
if (!(_PyIO_str_closed = PyUnicode_InternFromString("closed")))
goto fail; ADD_INTERNED(close)
if (!(_PyIO_str_decode = PyUnicode_InternFromString("decode"))) ADD_INTERNED(closed)
goto fail; ADD_INTERNED(decode)
if (!(_PyIO_str_encode = PyUnicode_InternFromString("encode"))) ADD_INTERNED(encode)
goto fail; ADD_INTERNED(fileno)
if (!(_PyIO_str_fileno = PyUnicode_InternFromString("fileno"))) ADD_INTERNED(flush)
goto fail; ADD_INTERNED(getstate)
if (!(_PyIO_str_flush = PyUnicode_InternFromString("flush"))) ADD_INTERNED(isatty)
goto fail; ADD_INTERNED(newlines)
if (!(_PyIO_str_getstate = PyUnicode_InternFromString("getstate"))) ADD_INTERNED(read)
goto fail; ADD_INTERNED(read1)
if (!(_PyIO_str_isatty = PyUnicode_InternFromString("isatty"))) ADD_INTERNED(readable)
goto fail; ADD_INTERNED(readinto)
if (!(_PyIO_str_newlines = PyUnicode_InternFromString("newlines"))) ADD_INTERNED(readline)
goto fail; ADD_INTERNED(reset)
if (!(_PyIO_str_nl = PyUnicode_InternFromString("\n"))) ADD_INTERNED(seek)
goto fail; ADD_INTERNED(seekable)
if (!(_PyIO_str_read = PyUnicode_InternFromString("read"))) ADD_INTERNED(setstate)
goto fail; ADD_INTERNED(tell)
if (!(_PyIO_str_read1 = PyUnicode_InternFromString("read1"))) ADD_INTERNED(truncate)
goto fail; ADD_INTERNED(write)
if (!(_PyIO_str_readable = PyUnicode_InternFromString("readable"))) ADD_INTERNED(writable)
goto fail;
if (!(_PyIO_str_readinto = PyUnicode_InternFromString("readinto"))) if (!_PyIO_str_nl &&
goto fail; !(_PyIO_str_nl = PyUnicode_InternFromString("\n")))
if (!(_PyIO_str_readline = PyUnicode_InternFromString("readline")))
goto fail;
if (!(_PyIO_str_reset = PyUnicode_InternFromString("reset")))
goto fail;
if (!(_PyIO_str_seek = PyUnicode_InternFromString("seek")))
goto fail;
if (!(_PyIO_str_seekable = PyUnicode_InternFromString("seekable")))
goto fail;
if (!(_PyIO_str_setstate = PyUnicode_InternFromString("setstate")))
goto fail;
if (!(_PyIO_str_tell = PyUnicode_InternFromString("tell")))
goto fail;
if (!(_PyIO_str_truncate = PyUnicode_InternFromString("truncate")))
goto fail;
if (!(_PyIO_str_write = PyUnicode_InternFromString("write")))
goto fail;
if (!(_PyIO_str_writable = PyUnicode_InternFromString("writable")))
goto fail; goto fail;
if (!(_PyIO_empty_str = PyUnicode_FromStringAndSize(NULL, 0))) if (!_PyIO_empty_str &&
!(_PyIO_empty_str = PyUnicode_FromStringAndSize(NULL, 0)))
goto fail; goto fail;
if (!(_PyIO_empty_bytes = PyBytes_FromStringAndSize(NULL, 0))) if (!_PyIO_empty_bytes &&
!(_PyIO_empty_bytes = PyBytes_FromStringAndSize(NULL, 0)))
goto fail; goto fail;
if (!(_PyIO_zero = PyLong_FromLong(0L))) if (!_PyIO_zero &&
!(_PyIO_zero = PyLong_FromLong(0L)))
goto fail; goto fail;
state->initialized = 1; state->initialized = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment