Skip to content

Fix inconsistent exception for JSONDecode error - #6097

Merged
nateprewitt merged 1 commit into
psf:mainfrom
nateprewitt:json_handling
Mar 28, 2022
Merged

Fix inconsistent exception for JSONDecode error#6097
nateprewitt merged 1 commit into
psf:mainfrom
nateprewitt:json_handling

Conversation

@nateprewitt

Copy link
Copy Markdown
Member

This PR should address #6084 by adding appropriate handling for alternative utf encodings. The previous change in #5856 only accounted for the happy path where we would attempt to load directly from .text. This patch will now ensure we're also catching and raising the appropriate exception when we guess the encoding based on byte sequencing.

When calling .json() it was possible to raise a
requests.exceptions.JSONDecodeError or ValueError
depending on whether the encoding is set.
@nateprewitt
nateprewitt merged commit 2d55176 into psf:main Mar 28, 2022
@nateprewitt
nateprewitt deleted the json_handling branch March 28, 2022 18:51
@nateprewitt nateprewitt added this to the 2.28.0 milestone Apr 7, 2022
@nateprewitt nateprewitt mentioned this pull request Jun 8, 2022
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 8, 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

Successfully merging this pull request may close these issues.

2 participants