Message12578

Author behackett
Recipients behackett
Date 2019-07-17.23:53:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1563407621.33.0.812314055861.issue2784@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2019-07-17 23:53:41behackettsetrecipients: + behackett
2019-07-17 23:53:41behackettsetmessageid: <1563407621.33.0.812314055861.issue2784@roundup.psfhosted.org>
2019-07-17 23:53:41behackettlinkissue2784 messages
2019-07-17 23:53:41behackettcreate