Ticket #3878: xml_serializer_error.txt

File xml_serializer_error.txt, 2.2 KB (added by Saik, 8 years ago)

uft8 problem with xml serializer

Line 
1xml = serializers.serialize("xml", Anymodel.objects.all())
2
3If the model data contains unicode characters the sealize process fails:
4
5-------
6exceptions.UnicodeDecodeError                        Traceback (most
7recent call last)
8
9/usr/local/lib/python2.4/site-packages/django/core/serializers/
10__init__.py in serialize(format, queryset, **options)
11     65     """
12     66     s = get_serializer(format)()
13---> 67     s.serialize(queryset, **options)
14     68     return s.getvalue()
15     69
16
17/usr/local/lib/python2.4/site-packages/django/core/serializers/base.py
18in serialize(self, queryset, **options)
19     38                     if field.rel is None:
20     39                         if self.selected_fields is None or
21field.attname in self.selected_fields:
22---> 40                             self.handle_field(obj, field)
23     41                     else:
24     42                         if self.selected_fields is None or
25field.attname[:-3] in self.selected_fields:
26
27/usr/local/lib/python2.4/site-packages/django/core/serializers/
28xml_serializer.py in handle_field(self, obj, field)
29     70             value = self.get_string_value(obj, field)
30     71             self.xml.characters(str(value))
31---> 72         else:
32     73             self.xml.addQuickElement("None")
33     74
34
35/usr/lib/python2.4/site-packages/_xmlplus/sax/saxutils.py in
36characters(self, content)
37    307
38    308     def characters(self, content):
39--> 309         writetext(self._out, content)
40    310
41    311     def ignorableWhitespace(self, content):
42
43/usr/lib/python2.4/site-packages/_xmlplus/sax/saxutils.py in
44writetext(stream, text, entities)
45    186     def writetext(stream, text, entities={}):
46    187         stream.errors = "xmlcharrefreplace"
47--> 188         stream.write(escape(text, entities))
48    189         stream.errors = "strict"
49    190 else:
50
51/usr/lib/python2.4/codecs.py in write(self, object)
52    176         """ Writes the object's contents encoded to
53self.stream.
54    177         """
55--> 178         data, consumed = self.encode(object, self.errors)
56    179         self.stream.write(data)
57    180
58
59UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
6054: ordinal not in range(128)
61------
62I'm using version from svn (rev. 4997) and the default charset, utf-8.
Back to Top