Commit bb5b92d3 authored by Antoine Pitrou's avatar Antoine Pitrou

Merge refleak fixes from 3.2

parents fff47ab3 fc1b6f00
...@@ -677,60 +677,47 @@ PyInit__io(void) ...@@ -677,60 +677,47 @@ 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) \
goto fail; if (!_PyIO_str_ ## name && \
if (!(_PyIO_str_closed = PyUnicode_InternFromString("closed"))) !(_PyIO_str_ ## name = PyUnicode_InternFromString(# name))) \
goto fail; goto fail;
if (!(_PyIO_str_decode = PyUnicode_InternFromString("decode")))
goto fail; ADD_INTERNED(close)
if (!(_PyIO_str_encode = PyUnicode_InternFromString("encode"))) ADD_INTERNED(closed)
goto fail; ADD_INTERNED(decode)
if (!(_PyIO_str_fileno = PyUnicode_InternFromString("fileno"))) ADD_INTERNED(encode)
goto fail; ADD_INTERNED(fileno)
if (!(_PyIO_str_flush = PyUnicode_InternFromString("flush"))) ADD_INTERNED(flush)
goto fail; ADD_INTERNED(getstate)
if (!(_PyIO_str_getstate = PyUnicode_InternFromString("getstate"))) ADD_INTERNED(isatty)
goto fail; ADD_INTERNED(newlines)
if (!(_PyIO_str_isatty = PyUnicode_InternFromString("isatty"))) ADD_INTERNED(read)
goto fail; ADD_INTERNED(read1)
if (!(_PyIO_str_newlines = PyUnicode_InternFromString("newlines"))) ADD_INTERNED(readable)
goto fail; ADD_INTERNED(readall)
if (!(_PyIO_str_nl = PyUnicode_InternFromString("\n"))) ADD_INTERNED(readinto)
goto fail; ADD_INTERNED(readline)
if (!(_PyIO_str_read = PyUnicode_InternFromString("read"))) ADD_INTERNED(reset)
goto fail; ADD_INTERNED(seek)
if (!(_PyIO_str_read1 = PyUnicode_InternFromString("read1"))) ADD_INTERNED(seekable)
goto fail; ADD_INTERNED(setstate)
if (!(_PyIO_str_readable = PyUnicode_InternFromString("readable"))) ADD_INTERNED(tell)
goto fail; ADD_INTERNED(truncate)
if (!(_PyIO_str_readall = PyUnicode_InternFromString("readall"))) ADD_INTERNED(write)
goto fail; ADD_INTERNED(writable)
if (!(_PyIO_str_readinto = PyUnicode_InternFromString("readinto")))
goto fail; if (!_PyIO_str_nl &&
if (!(_PyIO_str_readline = PyUnicode_InternFromString("readline"))) !(_PyIO_str_nl = PyUnicode_InternFromString("\n")))
goto fail; goto fail;
if (!(_PyIO_str_reset = PyUnicode_InternFromString("reset")))
goto fail; if (!_PyIO_empty_str &&
if (!(_PyIO_str_seek = PyUnicode_InternFromString("seek"))) !(_PyIO_empty_str = PyUnicode_FromStringAndSize(NULL, 0)))
goto fail; goto fail;
if (!(_PyIO_str_seekable = PyUnicode_InternFromString("seekable"))) if (!_PyIO_empty_bytes &&
goto fail; !(_PyIO_empty_bytes = PyBytes_FromStringAndSize(NULL, 0)))
if (!(_PyIO_str_setstate = PyUnicode_InternFromString("setstate"))) goto fail;
goto fail; if (!_PyIO_zero &&
if (!(_PyIO_str_tell = PyUnicode_InternFromString("tell"))) !(_PyIO_zero = PyLong_FromLong(0L)))
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;
if (!(_PyIO_empty_str = PyUnicode_FromStringAndSize(NULL, 0)))
goto fail;
if (!(_PyIO_empty_bytes = PyBytes_FromStringAndSize(NULL, 0)))
goto fail;
if (!(_PyIO_zero = PyLong_FromLong(0L)))
goto fail; goto fail;
state->initialized = 1; state->initialized = 1;
......
...@@ -2437,27 +2437,29 @@ _PyExc_Init(void) ...@@ -2437,27 +2437,29 @@ _PyExc_Init(void)
preallocate_memerrors(); preallocate_memerrors();
PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RuntimeError, NULL, NULL); if (!PyExc_RecursionErrorInst) {
if (!PyExc_RecursionErrorInst) PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RuntimeError, NULL, NULL);
Py_FatalError("Cannot pre-allocate RuntimeError instance for " if (!PyExc_RecursionErrorInst)
"recursion errors"); Py_FatalError("Cannot pre-allocate RuntimeError instance for "
else { "recursion errors");
PyBaseExceptionObject *err_inst = else {
(PyBaseExceptionObject *)PyExc_RecursionErrorInst; PyBaseExceptionObject *err_inst =
PyObject *args_tuple; (PyBaseExceptionObject *)PyExc_RecursionErrorInst;
PyObject *exc_message; PyObject *args_tuple;
exc_message = PyUnicode_FromString("maximum recursion depth exceeded"); PyObject *exc_message;
if (!exc_message) exc_message = PyUnicode_FromString("maximum recursion depth exceeded");
Py_FatalError("cannot allocate argument for RuntimeError " if (!exc_message)
"pre-allocation"); Py_FatalError("cannot allocate argument for RuntimeError "
args_tuple = PyTuple_Pack(1, exc_message); "pre-allocation");
if (!args_tuple) args_tuple = PyTuple_Pack(1, exc_message);
Py_FatalError("cannot allocate tuple for RuntimeError " if (!args_tuple)
"pre-allocation"); Py_FatalError("cannot allocate tuple for RuntimeError "
Py_DECREF(exc_message); "pre-allocation");
if (BaseException_init(err_inst, args_tuple, NULL)) Py_DECREF(exc_message);
Py_FatalError("init of pre-allocated RuntimeError failed"); if (BaseException_init(err_inst, args_tuple, NULL))
Py_DECREF(args_tuple); Py_FatalError("init of pre-allocated RuntimeError failed");
Py_DECREF(args_tuple);
}
} }
Py_DECREF(bltinmod); Py_DECREF(bltinmod);
......
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