Try to send bytes, but getting memoryview

Hi, can you explain me please, why i get this in my ubuntu 20.04 ? In 18.04 all is fine, but here i get this:

packages/sanic/server.py", line 336, in write_response
    self.keep_alive_timeout))
  File "/home/user/.pyenv/versions/testvenv/lib/python3.6/site-packages/sanic/response.py", line 173, in output
    body
TypeError: %b requires bytes, or an object that implements bytes, not 'memoryview'

thatk you!

Hi, I’m guessing its caused by some difference in Python version.

In Ubuntu 18.04 the default python is 3.6, and Ubuntu 20.04 the default python is 3.8.
Can you confirm please they are the two versions of python you are using?

Having said that, Sanic 19.6 and above is known to work perfectly fine on Python 3.8. What version of Sanic are you using?

I suppose that this comes from an expression like "%b" % memoryview(b"something"), yet that does not cause such error in Python 3.6.10, 3.7.7 nor 3.8.2, and the error message is also unknown to Google search. Can you test if the above expression when entered in Python interactive shell causes the error and if so, report your specific Python version? AFAIK memoryviews should be completely fine for the %b format. apt dist-upgrade could fix it if some earlier minor version of Python didn’t correctly handle this.

Also, let us know which version of Sanic you are using. The line numbers in your report do not correspond to current Sanic release 20.06 or to git master.