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

Commit

Permalink
Directly import json from the standard library. (#8259)
Browse files Browse the repository at this point in the history
By importing from canonicaljson the simplejson module was still being used
in some situations. After this change the std lib json is consistenty used
throughout Synapse.
  • Loading branch information
clokep authored Sep 8, 2020
1 parent cef0021 commit 72bec36
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog.d/8259.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Switch to the JSON implementation from the standard library.
2 changes: 1 addition & 1 deletion synapse/api/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
from typing import List

import jsonschema
from canonicaljson import json
from jsonschema import FormatChecker

from synapse.api.constants import EventContentFields
Expand Down
3 changes: 1 addition & 2 deletions synapse/app/admin_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import json
import logging
import os
import sys
import tempfile

from canonicaljson import json

from twisted.internet import defer, task

import synapse
Expand Down
2 changes: 1 addition & 1 deletion synapse/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import logging
import re

import attr
from canonicaljson import json

from twisted.internet import defer, task

Expand Down
5 changes: 3 additions & 2 deletions synapse/util/frozenutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from canonicaljson import json
import json

from frozendict import frozendict


Expand Down Expand Up @@ -66,5 +67,5 @@ def _handle_frozendict(obj):
# A JSONEncoder which is capable of encoding frozendicts without barfing.
# Additionally reduce the whitespace produced by JSON encoding.
frozendict_json_encoder = json.JSONEncoder(
default=_handle_frozendict, separators=(",", ":"),
allow_nan=False, separators=(",", ":"), default=_handle_frozendict,
)

0 comments on commit 72bec36

Please sign in to comment.