[issue15945] memoryview + bytes fails

Antoine Pitrou report at bugs.python.org
Sat Sep 15 14:37:25 CEST 2012


Antoine Pitrou added the comment:

Just prepend the empty bytestring if you want to make sure the result is a bytes object:

>>> b'' + memoryview(b'foo') + b'bar'
b'foobar'

I think the following limitation may be more annoying, though:

>>> b''.join([memoryview(b'foo'), b'bar'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: sequence item 0: expected bytes, memoryview found

----------
nosy: +pitrou

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


More information about the Python-bugs-list mailing list