Message8624

Author zyasoft
Recipients zyasoft
Date 2014-06-10.20:57:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1402433848.25.0.791107419198.issue2164@psf.upfronthosting.co.za>
In-reply-to
Content
Difference between CPython and Jython seen with this example:

# -*- coding: utf-8 -*-

import codecs

data = memoryview(b"中文")
text, decoded_bytes = codecs.utf_8_decode(data)
assert text == u"中文"
assert type(text) is unicode
assert decoded_bytes == 6

This works fine on CPython. On Jython, it fails with TypeError: utf_8_decode(): 1st arg can't be coerced to String

Current workaround is to use tobytes on the memoryview object:

text, decoded_bytes = codecs.utf_8_decode(data.tobytes())
History
Date User Action Args
2014-06-10 20:57:28zyasoftsetrecipients: + zyasoft
2014-06-10 20:57:28zyasoftsetmessageid: <1402433848.25.0.791107419198.issue2164@psf.upfronthosting.co.za>
2014-06-10 20:57:28zyasoftlinkissue2164 messages
2014-06-10 20:57:27zyasoftcreate