STINNER Victor added the comment:

sys.stderr.write() accepts Unicode (encoded to sys.stderr.encoding), whereas 
io.BytesIO.write() requires bytes:

>>> import sys; sys.stderr.write(u'\xe9\n')
é

>>> import io; io.BytesIO().write(u'\xe9\n')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'unicode' does not have the buffer interface


You should write an helper function (class with a write method) encoding 
Unicode strings.


> The same test runs without error on Python 3.

Yeah, it's now time to upgrade to Python 3 ;-)

----------

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

Reply via email to