diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2009-08-29 23:19:16 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2009-08-29 23:19:16 (GMT) |
commit | af0312af7a279ca1ec067728cd71cf8269b4f597 (patch) | |
tree | 6fbdbfa29e47c4e71759d20b9c08e10c55aecad8 /Modules | |
parent | f5d2879ab87d7096b0f50b25e9fd9ac5fb77f239 (diff) | |
download | cpython-af0312af7a279ca1ec067728cd71cf8269b4f597.zip cpython-af0312af7a279ca1ec067728cd71cf8269b4f597.tar.gz cpython-af0312af7a279ca1ec067728cd71cf8269b4f597.tar.bz2 |
Merged revisions 74582 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r74582 | amaury.forgeotdarc | 2009-08-30 01:00:38 +0200 (dim., 30 août 2009) | 10 lines
Merged revisions 74581 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r74581 | amaury.forgeotdarc | 2009-08-29 20:14:40 +0200 (sam., 29 août 2009) | 3 lines
#6750: TextIOWrapped could duplicate output when several threads write to it.
this affect text files opened with io.open(), and the print() function of py3k
........
................
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_io/textio.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 0f5a73d..b91852e 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -1213,11 +1213,18 @@ findchar(const Py_UNICODE *s, Py_ssize_t size, Py_UNICODE ch) static int _textiowrapper_writeflush(textio *self) { - PyObject *b, *ret; + PyObject *pending, *b, *ret; if (self->pending_bytes == NULL) return 0; - b = _PyBytes_Join(_PyIO_empty_bytes, self->pending_bytes); + + pending = self->pending_bytes; + Py_INCREF(pending); + self->pending_bytes_count = 0; + Py_CLEAR(self->pending_bytes); + + b = _PyBytes_Join(_PyIO_empty_bytes, pending); + Py_DECREF(pending); if (b == NULL) return -1; ret = PyObject_CallMethodObjArgs(self->buffer, @@ -1226,8 +1233,6 @@ _textiowrapper_writeflush(textio *self) if (ret == NULL) return -1; Py_DECREF(ret); - Py_CLEAR(self->pending_bytes); - self->pending_bytes_count = 0; return 0; } |