Skip to content

Conversation

@Prashant-thakur77
Copy link
Contributor

Fixes #13889

Summary

This PR removes Python 2.7 legacy code by updating JSON parsing exception handling from ValueError to json.JSONDecodeError. The changes make exception handling more specific and remove outdated compatibility code.

References

Fixes #13889

Reviewer guidance

  • Review the specific file changes to ensure only JSON parsing-related ValueError instances were updated
  • Verify that the exception handling logic remains the same, only the exception type changed
  • Confirm that Python 2 compatibility comments have been removed

Files changed:

  • kolibri/core/device/management/commands/provisiondevice.py
  • kolibri/plugins/init.py
  • kolibri/core/public/api.py
  • kolibri/core/fields.py

@github-actions github-actions bot added DEV: backend Python, databases, networking, filesystem... SIZE: small labels Nov 28, 2025
@Prashant-thakur77 Prashant-thakur77 deleted the update-jsondecodeerror-13889 branch November 28, 2025 20:10
@Prashant-thakur77 Prashant-thakur77 restored the update-jsondecodeerror-13889 branch November 28, 2025 20:11
@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

All these changes look good, there were two more instances of this kind of Py2.7 compatibility issue that I found: https://github.com/learningequality/kolibri/blob/develop/kolibri/core/discovery/utils/network/client.py#L228

Lastly, this is another attempt at the same issue, just disguised in a different way! https://github.com/learningequality/kolibri/blob/develop/kolibri/core/content/utils/content_manifest.py#L16 - just switching this to the import without the try except should be sufficient.

@rtibbles rtibbles self-assigned this Dec 1, 2025
@Prashant-thakur77
Copy link
Contributor Author

Prashant-thakur77 commented Dec 2, 2025

All these changes look good, there were two more instances of this kind of Py2.7 compatibility issue that I found:

@rtibbles
Thanks for pointing those out! I've updated both files:

kolibri/core/content/utils/content_manifest.py : Removed the try-except import block and changed to direct import: from json import JSONDecodeError
kolibri/core/discovery/utils/network/client.py : Removed ValueError from the exception tuple, now catching only requests.exceptions.JSONDecodeError

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

Excellent work @Prashant-thakur77 - thank you!

@rtibbles rtibbles merged commit a77f235 into learningequality:develop Dec 2, 2025
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DEV: backend Python, databases, networking, filesystem... SIZE: small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove Python 2.7 legacy: Update JSONDecodeError exception handling

2 participants