#30294: HttpResponse doesn't handle memoryview objects
-----------------------------------------+------------------------
Reporter: rhunwicks | Owner: nobody
Type: Bug | Status: new
Component: HTTP handling | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-----------------------------------------+------------------------
I am trying to write a `BinaryField` retrieved from the database into a
`HttpResponse`. When the database is Sqlite this works correctly, but
Postgresql returns the contents of the field as a `memoryview` object and
it seems like current Django doesn't like this combination:
{{{
#!python
from django.http import HttpResponse
# String content
response = HttpResponse("My Content")
response.content
# Out: b'My Content'
# This is correct
# Bytes content
response = HttpResponse(b"My Content")
response.content
# Out: b'My Content'
# This is also correct
# memoryview content
response = HttpResponse(memoryview(b"My Content"))
response.content
# Out: b'<memory at 0x7fcc47ab2648>'
# This is not correct, I am expecting b'My Content'
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30294>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.01d8e289236ff96f151feb39d229cd36%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.