This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 2to3 haven't convert buffer object to memoryview
Type: enhancement Stage:
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, bhy
Priority: normal Keywords:

Created on 2009-03-19 07:11 by bhy, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg83802 - (view) Author: Haoyu Bai (bhy) Date: 2009-03-19 07:10
The following example is valid in Python 2.6:

a = 'abc'
b = buffer(a)
print([repr(c) for c in b])

After 2to3 it, the 'buffer' isn't changed to memoryview, so then it is
not valid program in Python 3:

Traceback (most recent call last):
  File "bufferobj3.py", line 2, in <module>
    b = buffer(a)
NameError: name 'buffer' is not defined

However even it changed to memoryview the program still not valid because:

>>> memoryview('a')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot make memory view because object does not have the
buffer interface


I can reporduce this on both Python 3.0.1 and Python 3.1a1+ (py3k:70310).

Thanks!
msg83806 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-03-19 11:44
2to3 will convert buffer to memoryview, but not by default because as
you can see, it can be wrong. (Pass "-f buffer" to 2to3.) You can only
use memoryviews on bytes-like objects like b'a', and not unicode strings
(This is like 2.x.).
History
Date User Action Args
2022-04-11 14:56:46adminsetgithub: 49767
2009-03-19 11:44:04benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg83806

resolution: not a bug
2009-03-19 07:11:00bhycreate