Opened 18 years ago

Last modified 18 years ago

#3437 closed

djang.http.HttpResponse logic for _is_string is invalid — at Version 2

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

Description (last modified by Adrian Holovaty)

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 (2)

comment:1 by (removed), 18 years ago

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 by Adrian Holovaty, 18 years ago

Description: modified (diff)

(Fixed formatting in description)

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