Skip to content

response.json() raises inconsistent exception type #5794

@rowanseymour

Description

@rowanseymour

There are some comments about this on #4842 but I think it warrants its own issue.

If simplejson is present in the environment, the library uses it so .json() returns simplejson.errors.JSONDecodeError rather than json.decoder.JSONDecodeError

If I'm writing a library that uses requests I don't know what other libraries will be present in an environment. I expect that a method returns a consistent exception type that I can handle. As it stands, anyone writing a library (e.g. conda-forge/conda-smithy#1369, Vonage/vonage-python-sdk#197) has to check themselves if simplejson is present to know what exception type will be thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions