jur9526 / couchdb-python

Automatically exported from code.google.com/p/couchdb-python
Other
0 stars 0 forks source link

Field.__to_json does not like a str with unicode in it #160

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
In [2]: f = mapping.Field()

In [3]: f._to_json('é')

What is the expected output? What do you see instead?

this gives

UnicodeDecodeError                        Traceback (most recent call last)

/home/thomas/dev/ext/couchdb-python/<ipython console> in <module>()

/home/thomas/dev/ext/couchdb-python/couchdb/mapping.py in _to_json(self, value)
    108 
    109     def _to_json(self, value):
--> 110         return self._to_python(value)
    111 
    112 

/home/thomas/dev/ext/couchdb-python/couchdb/mapping.py in _to_python(self, 
value)
    105 
    106     def _to_python(self, value):
--> 107         return unicode(value)
    108 
    109     def _to_json(self, value):

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal 
not in range(128)

What version of the product are you using? On what operating system?

hg master

Original issue reported on code.google.com by svsam...@gmail.com on 9 Jan 2011 at 10:31

GoogleCodeExporter commented 9 years ago
I think this is not a bug. What do you expect `_to_json` has to do with 
byte-string? Mappings make no assumptions about encoding of its byte-string 
data.

Use unicode literals and unicode strings instead.

Original comment by daevaorn on 9 Jan 2011 at 10:42

GoogleCodeExporter commented 9 years ago
daevaorn is correct.

Original comment by matt.goo...@gmail.com on 9 Feb 2011 at 10:47