[Python-checkins] r69648 - in python/branches/io-c/Modules: _bufferedio.c _iomodule.h _textio.c io.c
antoine.pitrou
python-checkins at python.org
Sun Feb 15 20:58:17 CET 2009
Author: antoine.pitrou
Date: Sun Feb 15 20:58:16 2009
New Revision: 69648
Log:
Fix some refleaks
Modified:
python/branches/io-c/Modules/_bufferedio.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 20:58:16 2009
@@ -898,7 +898,7 @@
goto end;
}
Py_CLEAR(res);
- res = _PyBytes_Join(PyBytes_FromStringAndSize(NULL, 0), chunks);
+ res = _PyBytes_Join(_PyIO_empty_bytes, chunks);
end:
LEAVE_BUFFERED(self)
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 20:58:16 2009
@@ -127,3 +127,6 @@
extern PyObject *_PyIO_str_truncate;
extern PyObject *_PyIO_str_writable;
extern PyObject *_PyIO_str_write;
+
+extern PyObject *_PyIO_empty_str;
+extern PyObject *_PyIO_empty_bytes;
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 20:58:16 2009
@@ -1042,7 +1042,7 @@
if (self->pending_bytes == NULL)
return 0;
- b = _PyBytes_Join(PyBytes_FromStringAndSize(NULL, 0), self->pending_bytes);
+ b = _PyBytes_Join(_PyIO_empty_bytes, self->pending_bytes);
if (b == NULL)
return -1;
ret = PyObject_CallMethodObjArgs(self->buffer,
@@ -1359,8 +1359,7 @@
if (result != NULL && PyList_Append(chunks, result) < 0)
goto fail;
Py_CLEAR(result);
- result = PyUnicode_Join(PyUnicode_FromStringAndSize(NULL, 0),
- chunks);
+ result = PyUnicode_Join(_PyIO_empty_str, chunks);
if (result == NULL)
goto fail;
Py_CLEAR(chunks);
@@ -1618,7 +1617,7 @@
if (line != NULL && PyList_Append(chunks, line) < 0)
goto error;
Py_CLEAR(line);
- line = PyUnicode_Join(PyUnicode_FromStringAndSize(NULL, 0), chunks);
+ line = PyUnicode_Join(_PyIO_empty_str, chunks);
if (line == NULL)
goto error;
Py_DECREF(chunks);
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 20:58:16 2009
@@ -45,6 +45,9 @@
PyObject *_PyIO_str_writable;
PyObject *_PyIO_str_write;
+PyObject *_PyIO_empty_str;
+PyObject *_PyIO_empty_bytes;
+
PyDoc_STRVAR(module_doc,
"The io module provides the Python interfaces to stream handling. The\n"
@@ -754,6 +757,11 @@
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;
return m;
More information about the Python-checkins
mailing list