Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2to3 haven't convert buffer object to memoryview #49767

Closed
bhy mannequin opened this issue Mar 19, 2009 · 2 comments
Closed

2to3 haven't convert buffer object to memoryview #49767

bhy mannequin opened this issue Mar 19, 2009 · 2 comments
Labels
topic-2to3 type-feature A feature request or enhancement

Comments

@bhy
Copy link
Mannequin

bhy mannequin commented Mar 19, 2009

BPO 5517
Nosy @benjaminp

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2009-03-19.11:44:04.601>
created_at = <Date 2009-03-19.07:11:00.765>
labels = ['invalid', 'type-feature', 'expert-2to3']
title = "2to3 haven't convert buffer object to memoryview"
updated_at = <Date 2009-03-19.11:44:04.442>
user = 'https://bugs.python.org/bhy'

bugs.python.org fields:

activity = <Date 2009-03-19.11:44:04.442>
actor = 'benjamin.peterson'
assignee = 'none'
closed = True
closed_date = <Date 2009-03-19.11:44:04.601>
closer = 'benjamin.peterson'
components = ['2to3 (2.x to 3.x conversion tool)']
creation = <Date 2009-03-19.07:11:00.765>
creator = 'bhy'
dependencies = []
files = []
hgrepos = []
issue_num = 5517
keywords = []
message_count = 2.0
messages = ['83802', '83806']
nosy_count = 2.0
nosy_names = ['benjamin.peterson', 'bhy']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue5517'
versions = ['Python 2.6', 'Python 3.0', 'Python 3.1', 'Python 2.7']

@bhy
Copy link
Mannequin Author

bhy mannequin commented Mar 19, 2009

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!

@bhy bhy mannequin added topic-2to3 type-feature A feature request or enhancement labels Mar 19, 2009
@benjaminp
Copy link
Contributor

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.).

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-2to3 type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant