Inada Naoki <songofaca...@gmail.com> added the comment:

This is not the problem only in the optimization. _textiowrapper_writeflush 
need to create buffer bytes object anyway and if it cause MemoryError, the 
TextIOWrapper can not flush internal buffer forever.

  stdout.write("small text")
  stdout.write("very large text")  # Calls writeflush, but can not allocate 
buffer.

This example would stuck on same situation without the optimization.


But the optimization made the problem easy to happen. Now the problem happend 
with only one learge text.

Idea to fix this problem:

* If input text is large (>1M?)
  * Flush buffer before adding the large text to the buffer.
  * Encode the text and write it to self->buffer soon. Do not put it into 
internal buffer (self->pending_bytes).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43260>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to