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

frombuffer 'hello world' example does not work in Py3 #8933

Closed
hpaulj opened this issue Apr 12, 2017 · 2 comments
Closed

frombuffer 'hello world' example does not work in Py3 #8933

hpaulj opened this issue Apr 12, 2017 · 2 comments

Comments

@hpaulj
Copy link

hpaulj commented Apr 12, 2017

np.frombuffer has an example making a S1 array from "hello world". That works fine in Python 2, but in Python3 raises an error - the string object doesn't have a __buffer__ attribute.

 s = b'hello world' 

works.

I don't know if it is simpler to use separate PY2 and PY3 examples, or to come up with an example that doesn't highlight this difference. frombuffer is not usually needed by beginning to intermediate users, so an overly simple string/bytestring example might be more misleading than helpful.

http://stackoverflow.com/questions/43362986/numpy-frombuffer-attributeerror-str-object-has-no-attribute-buffer

@jakirkham
Copy link
Contributor

Should add this is also an issue with np.fromstring.

@mattip
Copy link
Member

mattip commented Feb 27, 2020

Closing, the frombuffer documentation has been updated and fromstring accepts a Python3 string.

@mattip mattip closed this as completed Feb 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants