Skip to content
Advertisement

NameError: name ‘buffer’ is not defined

Python2 code:

JavaScript

What is the python3 equivalent? I tried to replace buffer with memoryview() but than name error becomes a type error: TypeError: memoryview: a bytes-like object is required, not ‘str’.

I’m pretty sure that this should be a string and not a byte.

Can someone help me?

Buffer function for python 3+ IS NOT THE ANSWER!

Advertisement

Answer

Adapting answers from Buffer function for python 3+

JavaScript

memoryview expects bytes. Python 3 makes a distinction between bytes and strings now.

Advertisement