This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients benjamin.peterson, ezio.melotti, hynek, pitrou, serhiy.storchaka, stutzbach, vstinner
Date 2014-01-28.20:26:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1390940815.88.0.957874925248.issue20424@psf.upfronthosting.co.za>
In-reply-to
Content
Unlike to io.StringIO, _pyio.StringIO doesn't work with lone surrogates.

>>> import io, _pyio
>>> io.StringIO('\ud880')
<_io.StringIO object at 0xb71426ec>
>>> _pyio.StringIO('\ud880')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/_pyio.py", line 2065, in __init__
    self.write(initial_value)
  File "/home/serhiy/py/cpython/Lib/_pyio.py", line 1629, in write
    b = encoder.encode(s)
  File "/home/serhiy/py/cpython/Lib/encodings/utf_8.py", line 20, in encode
    return codecs.utf_8_encode(input, self.errors)[0]
UnicodeEncodeError: 'utf-8' codec can't encode character '\ud880' in position 0: surrogates not allowed

Proposed patch adds support of lone surrogates to _pyio.StringIO.
History
Date User Action Args
2014-01-28 20:26:55serhiy.storchakasetrecipients: + serhiy.storchaka, pitrou, vstinner, benjamin.peterson, stutzbach, ezio.melotti, hynek
2014-01-28 20:26:55serhiy.storchakasetmessageid: <1390940815.88.0.957874925248.issue20424@psf.upfronthosting.co.za>
2014-01-28 20:26:55serhiy.storchakalinkissue20424 messages
2014-01-28 20:26:55serhiy.storchakacreate