Django

Code

Ticket #7990 (closed: fixed)

Opened 4 months ago

Last modified 4 months ago

serializers should use StringIO and not cStringIO

Reported by: anonymous Assigned to: nobody
Milestone: 1.0 beta Component: Core framework
Version: SVN Keywords: cstringio serializers unicode
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

there is a slight difference between cStringIO and StringIO which makes cStringIO unusable for unicode data:

>>> import StringIO
>>> import cStringIO
>>> s1 = StringIO.StringIO(u'unicode text')
>>> s2 = cStringIO.StringIO(u'unicode text')
>>> s1.read()
u'unicode text'
>>> s2.read()
'u\x00\x00\x00n\x00\x00\x00i\x00\x00\x00c\x00\x00\x00o\x00\x00\x00d\x00\x00\x00e\x00\x00\x00 \x00\x00\x00t\x00\x00\x00e\x00\x00\x00x\x00\x00\x00t\x00\x00\x00'

This makes serializers such as json or yaml unusable for unicode data.

Attachments

Change History

07/27/08 17:51:06 changed by Simon Greenhill

  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

07/27/08 18:20:23 changed by mtredinnick

The particular problem reported here is only present in python 2.3 and 2.4. However, more significantly, even in python 2.5, cStringIO cannot handle non-ASCII unicode strings. This is a documented feature of the module, so for that reason, we should change it.

07/30/08 05:43:07 changed by russellm

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

(In [8151]) Fixed #7990 -- Modified serializers to use StringIO, rather than cStringIO, due to potential unicode issues.


Add/Change #7990 (serializers should use StringIO and not cStringIO)




Change Properties
Action