Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

response.json() raises inconsistent exception type #6084

Closed
JeremyVriens opened this issue Mar 15, 2022 · 2 comments
Closed

response.json() raises inconsistent exception type #6084

JeremyVriens opened this issue Mar 15, 2022 · 2 comments

Comments

@JeremyVriens
Copy link

This is a follow up on #5794, the issue is marked as resolved, but it's not completely resolved.

Expected Result

When no encoding is returned, you have simplejson installed and the content is not JSON, a requests.exceptions.JSONDecodeError should be raised.

Actual Result

A simplejson.errors.JSONDecodeError is raised.

Reproduction Steps

In the PR, related to the issue mentioned, the JSONDecodeError is only caught when there's an encoding (https://github.com/psf/requests/pull/5856/files#diff-633feaee006d302c2988a1f73e39e76a55ec077b595d8c0a093f72d75fb1799cR909-R911), this except clause should also be there a few lines above (when there's no encoding).

@nateprewitt
Copy link
Member

Hi @JeremyVriens, thanks for bringing this to our attention! This was definitely a miss in the original PR. I've pushed up a quick test and fix (#6097) to appropriately catch and wrap the JSONDecodeError. Please let us know if you have any comments or concerns on the PR, otherwise, this should be addressed in the next minor release.

@nateprewitt
Copy link
Member

We've gone ahead and merged #6097. I'll close this since it's now on the path for release, but please feel free to leave any further comments here or on the PR.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants