Document fetch fails when uses its default json decoder and module simplejson is present #409
Comments
This affects users using IBM Cloud Functions (OpenWhisk/Serveless) using the python runtimes, the runtimes include multiple packages for example the
Like @dariosm I also I agree that the cloudant library needs to handle the 2 cases properyly were the |
A pretty simple workaround for this issue, that I have working live in IBM Cloud Functions, is:
|
Thanks for reporting this. The requests documentation for
The documentation for
and
So what we're doing should be valid. However, I agree with your assessment, For reference it appears that this awkward undocumented preferential import of |
@ricellis I also thought about reporting to |
@dariosm @csantanapr until we have a solution other workarounds could be:
|
@ricellis will look into reverting back to The thing is the Cloud Functions environment is fixed for users using the UI interface on bluemix interface, and they don't have an option to select which version of python or python-cloudant lib. |
I think that is a good plan. We will only consider engineering a workaround if
I don't understand what
Requests 2.x does break when
We will not be special casing for |
workaround with problem with cloudant lib cloudant/python-cloudant#409
* revert back cloudant from 2.10.0 to 2.9.0 workaround with problem with cloudant lib cloudant/python-cloudant#409 * update changelog
Thanks @ricellis for the update. I think another option would be to have a check if |
One piece of data, I tried to remove |
@ricellis what's the latest status on this? |
@csantanapr as you can see from psf/requests#4842 I proposed a fix, which they didn't accept. I asked whether they were willing to consider fixing it at all and they went quiet. I've asked again, if we don't hear anything in the next day or two we'll fallback to doing the large-scale changes to workaround in our lib. |
Thanks keep us posted |
This is awsome thank you 🙏🏻 |
@csantanapr yw, we'll do a release with the fix real soon. |
Should be resolved in https://github.com/cloudant/python-cloudant/releases/tag/2.10.1 |
Bug Description
Document.fetch()
fails when it uses its default json decoder andsimplejson
is in the environment.Steps to reproduce and code sample to demonstrate the issue
To reproduce, just run a simple document fetch like this having
simplejson
package in the environment:Expected behavior
The full document should be retrieved by
fetch
function, instead whensimplejson
is reachable in the environment, it will raise the following error:What actually happened
Starting in this line:
self.update(resp.json(cls=self.decoder))
:json()
function fromrequests.models
is called with argumentcls
and valuejson.JSONDecoder
, asself.decoder
was initialized by default when no decoder is passed toDocument
requests.compat
module: whensimplejson
is present, then the json decoder implementation comes from that packagesimplejson
package is used to load the contents of the responsecls
is ajson.JSONDecoder
(see point 1), and it does not expect an argument calledencoding
, thus aTypeError
is raised.Environment details
Version affected:
2.10.0
Note that in version
2.9.0
,cls=self.decoder
was not passed toresp.json()
.The text was updated successfully, but these errors were encountered: