Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Doc write exception with unicode characters #235

@djc

Description

@djc

From hhmw56...@gmail.com on April 28, 2014 23:42:35

What steps will reproduce the problem? The following test script fails with 0.9, but works fine with 0.8:

import json
import couchdb

db = couchdb.Server(u"https://:@")['']
docs = [{u'Type':"TestDoc", u'Test':True, u'val':unichr(40960)}]
ret = db.update( docs )
print ret What is the expected output? What do you see instead? The write should succeed.

The exception is:

File "couch_encoding_test.py", line 10, in
ret = db.update( docs )
File "/usr/local/lib/python2.7/dist-packages/CouchDB-0.9-py2.7.egg/couchdb/client.py", line 764, in update
_, _, data = self.resource.post_json('_bulk_docs', body=content)
File "/usr/local/lib/python2.7/dist-packages/CouchDB-0.9-py2.7.egg/couchdb/http.py", line 527, in post_json
*_params)
File "/usr/local/lib/python2.7/dist-packages/CouchDB-0.9-py2.7.egg/couchdb/http.py", line 546, in _request_json
headers=headers, *_params)
File "/usr/local/lib/python2.7/dist-packages/CouchDB-0.9-py2.7.egg/couchdb/http.py", line 542, in _request
credentials=self.credentials)
File "/usr/local/lib/python2.7/dist-packages/CouchDB-0.9-py2.7.egg/couchdb/http.py", line 327, in request
resp = _try_request_with_retries(iter(self.retry_delays))
File "/usr/local/lib/python2.7/dist-packages/CouchDB-0.9-py2.7.egg/couchdb/http.py", line 285, in _try_request_with_retries
return _try_request()
File "/usr/local/lib/python2.7/dist-packages/CouchDB-0.9-py2.7.egg/couchdb/http.py", line 307, in _try_request
conn.endheaders(body)
File "/usr/lib/python2.7/httplib.py", line 954, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 812, in _send_output
msg += message_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0xea in position 52: ordinal not in range(128) What version of the product are you using? On what operating system? couchdb-python 0.9, ubuntu 12.04 Please provide any additional information below. If the parameter to couchdb.Server is a str instead of a unicode object, the script executes correctly.

Original issue: http://code.google.com/p/couchdb-python/issues/detail?id=235

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions