Issue2788

classification
Title: utf_8_decode doesn't support memoryview
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7
Milestone:
process
Status: open Resolution: duplicate
Dependencies: codecs do not accept memoryview objects for decoding
View: 2164
Superseder:
Assigned To: Nosy List: behackett, jeff.allen
Priority: normal Keywords:

Created on 2019-07-19.02:03:03 by behackett, last changed 2019-07-21.07:25:12 by jeff.allen.

Messages
msg12588 (view) Author: Bernie Hackett (behackett) Date: 2019-07-19.02:03:03
Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_202
Type "help", "copyright", "credits" or "license" for more information.
>>> mm = memoryview("foo")
>>> from codecs import utf_8_decode
>>> utf_8_decode(mm)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: utf_8_decode(): 1st arg can't be coerced to String

Python 2.7.16 (default, Jul  5 2019, 09:06:49) 
[GCC 9.1.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> mm = memoryview("foo")
>>> from codecs import utf_8_decode
>>> utf_8_decode(mm)
(u'foo', 3)
msg12602 (view) Author: Jeff Allen (jeff.allen) Date: 2019-07-21.07:25:11
You're right. I've wanted to fix that for ages (see #2164), for all the codecs in Java, but it didn't make the cut for 2.7.2.

There's a sloppy way, but to take advantage of the efficiency of the buffer interface seemed to entail quite a bit of re-writing and API risk.
History
Date User Action Args
2019-07-21 07:25:12jeff.allensetpriority: normal
resolution: duplicate
dependencies: + codecs do not accept memoryview objects for decoding
messages: + msg12602
nosy: + jeff.allen
2019-07-19 02:03:03behackettcreate