Opened 11 years ago

Closed 11 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

Description

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/handlers.py", line 138, in run
    self.finish_response()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/wsgiref/handlers.py", line 178, in finish_response
    for data in self.result:
  File "/Users/ambv/Documents/Projekty/Python/django/django/http/response.py", line 288, in __next__
    return self.make_bytes(next(self._iterator))
  File "/Users/ambv/Documents/Projekty/Python/django/django/http/response.py", line 270, in make_bytes
    return bytes(value)
TypeError: string argument without an encoding

Patch: https://github.com/django/django/pull/1191

Tested on both Python 3.3 and 2.7.

Change History (2)

comment:1 by Łukasz Langa, 11 years ago

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

comment:2 by Baptiste Mispelon, 11 years ago

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