From: Bernie H. <re...@bu...> - 2019-07-17 23:53:50
|
New submission from Bernie Hackett <be...@10...>: In CPython 2 and 3 and PyPy 2 and 3 memoryview only accepts objects that implement the buffer protocol. unicode / python3 str don't implement the buffer protocol so memoryview doesn't accept them, but memoryview in Jython does. 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. >>> memoryview(u"foobar").tobytes() 'foobar' Python 3.6.9 (default, Jul 17 2019, 12:02:47) [GCC 9.1.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> memoryview(u"foobar").tobytes() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: memoryview: a bytes-like object is required, not 'str' >>> Python 2.7.16 (default, Mar 6 2019, 09:58:35) [GCC 8.2.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> memoryview(u"foobar").tobytes() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: cannot make memory view because object does not have the buffer interface ---------- components: Core messages: 12578 nosy: behackett severity: normal status: open title: memoryview accepts unicode strings as input type: behaviour versions: Jython 2.7 _______________________________________ Jython tracker <re...@bu...> <https://bugs.jython.org/issue2784> _______________________________________ |