Opened 8 years ago

Closed 8 years ago

#3437 closed (fixed)

djang.http.HttpResponse logic for _is_string is invalid

Reported by: (removed) Owned by: adrian
Component: Core (Other) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by adrian)

code currently does effectively thus-

if hasattr(content, '__iter__'):
 self._is_string = False
 self._container = content
else:
 self._is_string = True
 self._container = [content]

Problem is that string objects support iteration.

Fix for it's simple; just do

if not isinstance(content, basestring) and hasattr(content, '__iter__'):

(yes y'all prefer seperate patches, but it's a one liner ;)

Change History (3)

comment:1 Changed 8 years ago by (removed)

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

pardon the bugspam; forgot about wikiformatting, adding the properly formatted snippet...

if hasattr(content, 'iter'):
 self._is_string = False
 self._container = content
else:
 self._is_string = True
 self._container = [content]

comment:2 Changed 8 years ago by adrian

  • Description modified (diff)

(Fixed formatting in description)

comment:3 Changed 8 years ago by adrian

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

(In [4472]) Fixed #3437 -- Fixed incorrect logic in django.http.HttpResponse calculation of _is_string. Thanks, Brian Harring

Note: See TracTickets for help on using tickets.
Back to Top