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

Compatibility issues with JSONDecodeError #64

Merged
merged 1 commit into from
Sep 9, 2021
Merged

Conversation

kbairak
Copy link

@kbairak kbairak commented Sep 9, 2021

requests is somewhat inconsistent with how it raises this exception.
(psf/requests#5794)

Depending on the environment, the following can happen during response.json():

  • Python2 and no simplejson, a ValueError will be raised
  • Python2 and simplejson, a simplejson.JSONDecodeError will be raised
  • Python3 and no simplejson, a json.JSONDecodeError will be raised
  • Python3 and simplejson, a simplejson.JSONDecodeError will be raised

The following wil make sure that catching transifex.api.jsonapi.compat.JSONDecodeError in a try: response.json() block will always work

`requests` is somewhat inconsistent with how it raises this exception.
(psf/requests#5794)

Depending on the environment, the following can happen during
`response.json`:

  - Python2 and no `simplejson`, a `ValueError` will be raised
  - Python2 and `simplejson`, a `simplejson.JSONDecodeError` will be
    raised
  - Python3 and no `simplejson`, a `json.JSONDecodeError` will be raised
  - Python3 and `simplejson`, a `simplejson.JSONDecodeError` will be
    raised

The following wil make sure that catching
`transifex.api.jsonapi.compat.JSONDecodeError` in a `try:
response.json()`
block will always work
@codecov-commenter
Copy link

codecov-commenter commented Sep 9, 2021

Codecov Report

Merging #64 (e425373) into devel (ec29fd1) will decrease coverage by 0.21%.
The diff coverage is 90.90%.

Impacted file tree graph

@@            Coverage Diff             @@
##            devel      #64      +/-   ##
==========================================
- Coverage   77.62%   77.41%   -0.22%     
==========================================
  Files          46       46              
  Lines        3710     3719       +9     
==========================================
- Hits         2880     2879       -1     
- Misses        830      840      +10     
Impacted Files Coverage Δ
transifex/api/jsonapi/compat.py 95.65% <90.90%> (-4.35%) ⬇️
transifex/_version.py 41.93% <0.00%> (-3.23%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec29fd1...e425373. Read the comment docs.

Copy link

@kostasgeo kostasgeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kbairak kbairak merged commit d467e82 into devel Sep 9, 2021
@kbairak kbairak deleted the api_sdk_jsondecodeerror branch September 9, 2021 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants