Code

#20472 closed Bug (fixed)

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

Reported by: ambv Owned by: ambv
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.

Attachments (0)

Change History (2)

comment:1 Changed 11 months ago by ambv

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to ambv
  • Patch needs improvement unset
  • Status changed from new to assigned

comment:2 Changed 11 months ago by bmispelon

  • Resolution set to fixed
  • Status changed from assigned to closed

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.