Skip to content

Fix reading JSON on Python 3.9+ (removed encoding kwarg) - #52

Open
ARYAMANN7279 wants to merge 1 commit into
INCF:masterfrom
ARYAMANN7279:fix/json-encoding-kwarg
Open

ARYAMANN7279 wants to merge 1 commit into
INCF:masterfrom
ARYAMANN7279:fix/json-encoding-kwarg

Conversation

@ARYAMANN7279

Copy link
Copy Markdown

Reading a JSON-serialised document fails on Python 3.9 and later:

TypeError: JSONDecoder.__init__() got an unexpected keyword argument 'encoding'

JSONUnserializer.from_file and from_str always passed encoding= to json.load(s), and Python 3.9 removed that argument. This only passes it when a value is given, so the default path works again and behaviour for older Pythons stays the same.

On Python 3.14 with sympy 1.14 this fixes 4 failing tests in test/unittests (indices_test serialization, test_to_str, test_flat_body, and the comprehensive round trip). Before: 6 failed, 216 passed. After: 2 failed, 220 passed. The 2 left are the assert_ calls that #49 already covers.

json.load and json.loads dropped the 'encoding' argument in Python 3.9,
so reading JSON documents raised TypeError. Only pass it when given.
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.

1 participant