Opened 5 years ago

Closed 5 years ago

#20472 closed Bug (fixed)

response.content should be bytes on both Python 2 and 3

Reported by: Łukasz Langa Owned by: Łukasz Langa
Component: HTTP handling Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


conditional_content_removal() currently overwrites response.content to a native empty string which causes the following error when using both ConditionalGetMiddleware and GZipMiddleware on Python 3:

Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/wsgiref/", line 138, in run
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/wsgiref/", line 178, in finish_response
    for data in self.result:
  File "/Users/ambv/Documents/Projekty/Python/django/django/http/", line 288, in __next__
    return self.make_bytes(next(self._iterator))
  File "/Users/ambv/Documents/Projekty/Python/django/django/http/", line 270, in make_bytes
    return bytes(value)
TypeError: string argument without an encoding


Tested on both Python 3.3 and 2.7.

Change History (2)

comment:1 Changed 5 years ago by Łukasz Langa

Owner: changed from nobody to Łukasz Langa
Status: newassigned

comment:2 Changed 5 years ago by Baptiste Mispelon

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.
Back to Top