#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 , 16 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 16 years ago
comment:3 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
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.