[issue13056] test_multibytecodec.py:TestStreamWriter is skipped after PEP393

Ezio Melotti report at bugs.python.org
Thu Sep 29 03:38:20 CEST 2011


New submission from Ezio Melotti <ezio.melotti at gmail.com>:

The test at Lib/test/test_multibytecodec.py:178 checks for len('\U00012345') == 2, and with PEP393 this is always False.
I tried to run the tests with a few changes and they seem to work, but the code doesn't raise any exception on c.reset():

---->8-------->8-------->8-------->8----
import io, codecs
s = io.BytesIO()
c = codecs.getwriter('gb18030')(s)
c.write('123'); s.getvalue()
c.write('\U00012345'); s.getvalue()
c.write('\U00012345' + '\uac00\u00ac'); s.getvalue()
c.write('\uac00'); s.getvalue()
c.reset()
s.getvalue()
---->8-------->8-------->8-------->8----

Result:
>>> import io, codecs
>>> s = io.BytesIO()
>>> c = codecs.getwriter('gb18030')(s)
>>> c.write('123'); s.getvalue()
b'123'
>>> c.write('\U00012345'); s.getvalue()
b'123\x907\x959'
>>> # '\U00012345'[0] is the same of '\U00012345' now
>>> c.write('\U00012345' + '\uac00\u00ac'); s.getvalue()
b'123\x907\x959\x907\x959\x827\xcf5\x810\x851'
>>> c.write('\uac00'); s.getvalue()
b'123\x907\x959\x907\x959\x827\xcf5\x810\x851\x827\xcf5'
>>> c.reset()  # is this supposed to raise an error?
>>> s.getvalue()
b'123\x907\x959\x907\x959\x827\xcf5\x810\x851\x827\xcf5'

Victor suggested to wait until multibytecodec gets ported to the new API before fixing this.

----------
components: Tests
messages: 144583
nosy: ezio.melotti, haypo, loewis
priority: normal
severity: normal
stage: needs patch
status: open
title: test_multibytecodec.py:TestStreamWriter is skipped after PEP393
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13056>
_______________________________________


More information about the Python-bugs-list mailing list