lanto03 / couchdb-python

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

TypeError raised in json.encode is hidden, and should not be. #202

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If you try update a document with a value that is a type that can't be encoded 
by json, json.encode raises a TypeError, but this is hidden by 
couchdb-python[1], and a different error is raised in later code because the 
request body has not been encoded[2].

I feel that the json.encode TypeError should not be hidden by couchdb-python. 
This error is probably because of a mistake that a developer has made, and if 
the developer can see the error, it makes it much easier for them to realise 
what they have done wrong.

[1] http.py - line 175-178
[2] Traceback (most recent call last):
  File "/home/garyvdm/video_db/video_db/update_files.py", line 101, in run
    self.db.update((file,))
  File "/home/garyvdm/video_db/ve/lib/python2.7/site-packages/CouchDB-0.8-py2.7.egg/couchdb/client.py", line 733, in update
    _, _, data = self.resource.post_json('_bulk_docs', body=content)
  File "/home/garyvdm/video_db/ve/lib/python2.7/site-packages/CouchDB-0.8-py2.7.egg/couchdb/http.py", line 399, in post_json
    status, headers, data = self.post(*a, **k)
  File "/home/garyvdm/video_db/ve/lib/python2.7/site-packages/CouchDB-0.8-py2.7.egg/couchdb/http.py", line 381, in post
    **params)
  File "/home/garyvdm/video_db/ve/lib/python2.7/site-packages/CouchDB-0.8-py2.7.egg/couchdb/http.py", line 419, in _request
    credentials=self.credentials)
  File "/home/garyvdm/video_db/ve/lib/python2.7/site-packages/CouchDB-0.8-py2.7.egg/couchdb/http.py", line 239, in request
    resp = _try_request_with_retries(iter(self.retry_delays))
  File "/home/garyvdm/video_db/ve/lib/python2.7/site-packages/CouchDB-0.8-py2.7.egg/couchdb/http.py", line 196, in _try_request_with_retries
    return _try_request()
  File "/home/garyvdm/video_db/ve/lib/python2.7/site-packages/CouchDB-0.8-py2.7.egg/couchdb/http.py", line 222, in _try_request
    chunk = body.read(CHUNK_SIZE)
AttributeError: 'dict' object has no attribute 'read'

Original issue reported on code.google.com by gary...@gmail.com on 9 Oct 2011 at 1:34

GoogleCodeExporter commented 8 years ago
I apologise. I see this has already been fixed it the trunk version.

Original comment by gary...@gmail.com on 9 Oct 2011 at 1:45

GoogleCodeExporter commented 8 years ago
No problem. It obviously means it's time to get a new release out!

Original comment by matt.goo...@gmail.com on 11 Oct 2011 at 11:09