Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Use the standard library JSON. #7936

Merged
merged 6 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/7936.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Switch to the JSON implementation from the standard library and bump the minimum version of the canonicaljson library to 1.2.0.
12 changes: 12 additions & 0 deletions synapse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
""" This is a reference implementation of a Matrix homeserver.
"""

import json
import os
import sys

Expand All @@ -25,6 +26,9 @@
print("Synapse requires Python 3.5 or above.")
sys.exit(1)

# Twisted and canonicaljson will fail to import when this file is executed to
# get the __version__ during a fresh install. That's OK and subsequent calls to
# actually start Synapse will import these libraries fine.
try:
from twisted.internet import protocol
from twisted.internet.protocol import Factory
Expand All @@ -36,6 +40,14 @@
except ImportError:
pass

# Use the standard library json implementation instead of simplejson.
try:
from canonicaljson import set_json_library

set_json_library(json)
except ImportError:
richvdh marked this conversation as resolved.
Show resolved Hide resolved
pass

__version__ = "1.18.0rc2"

if bool(os.environ.get("SYNAPSE_TEST_PATCH_LOG_CONTEXTS", False)):
Expand Down
2 changes: 1 addition & 1 deletion synapse/python_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"jsonschema>=2.5.1",
"frozendict>=1",
"unpaddedbase64>=1.1.0",
"canonicaljson>=1.1.3",
"canonicaljson>=1.2.0",
# we use the type definitions added in signedjson 1.1.
"signedjson>=1.1.0",
"pynacl>=1.2.1",
Expand Down