Django

Code

Ticket #3437 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

djang.http.HttpResponse logic for _is_string is invalid

Reported by: Brian Harring <ferringb@gmail.com> Assigned to: adrian
Milestone: Component: Core framework
Version: SVN Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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 ;)

Attachments

Change History

02/05/07 18:14:34 changed by Brian Harring <ferringb@gmail.com>

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

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]

02/09/07 21:53:52 changed by adrian

  • description changed.

(Fixed formatting in description)

02/09/07 21:56:21 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #3437 (djang.http.HttpResponse logic for _is_string is invalid)




Change Properties
Action