Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#7990 closed (fixed)

serializers should use StringIO and not cStringIO

Reported by: anonymous Owned by: nobody
Component: Core (Other) Version: dev
Severity: Keywords: cstringio serializers unicode
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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.

Change History (4)

comment:1 by Simon Greenhill, 16 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Malcolm Tredinnick, 16 years ago

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.

comment:3 by Russell Keith-Magee, 16 years ago

Resolution: fixed
Status: newclosed

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

comment:4 by Jacob, 13 years ago

milestone: 1.0 beta

Milestone 1.0 beta deleted

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