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

Commit

Permalink
Do not use simplejson in Synapse.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Jul 7, 2020
1 parent 76dbd7b commit bca03f7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 25 deletions.
1 change: 1 addition & 0 deletions changelog.d/7800.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Switch from simplejson to the standard library json.
11 changes: 2 additions & 9 deletions synapse/replication/tcp/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,11 @@
allowed to be sent by which side.
"""
import abc
import json
import logging
import platform
from typing import Tuple, Type

if platform.python_implementation() == "PyPy":
import json

_json_encoder = json.JSONEncoder()
else:
import simplejson as json # type: ignore[no-redef] # noqa: F821

_json_encoder = json.JSONEncoder(namedtuple_as_object=False) # type: ignore[call-arg] # noqa: F821
_json_encoder = json.JSONEncoder()

logger = logging.getLogger(__name__)

Expand Down
6 changes: 2 additions & 4 deletions synapse/storage/data_stores/main/schema/delta/25/fts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
# 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
import logging

import simplejson

from synapse.storage.engines import PostgresEngine, Sqlite3Engine
from synapse.storage.prepare_database import get_statements

Expand Down Expand Up @@ -66,7 +64,7 @@ def run_create(cur, database_engine, *args, **kwargs):
"max_stream_id_exclusive": max_stream_id + 1,
"rows_inserted": 0,
}
progress_json = simplejson.dumps(progress)
progress_json = json.dumps(progress)

sql = (
"INSERT into background_updates (update_name, progress_json)"
Expand Down
6 changes: 2 additions & 4 deletions synapse/storage/data_stores/main/schema/delta/27/ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
# 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
import logging

import simplejson

from synapse.storage.prepare_database import get_statements

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -45,7 +43,7 @@ def run_create(cur, database_engine, *args, **kwargs):
"max_stream_id_exclusive": max_stream_id + 1,
"rows_inserted": 0,
}
progress_json = simplejson.dumps(progress)
progress_json = json.dumps(progress)

sql = (
"INSERT into background_updates (update_name, progress_json)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
# 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
import logging

import simplejson

from synapse.storage.engines import PostgresEngine
from synapse.storage.prepare_database import get_statements

Expand Down Expand Up @@ -50,7 +48,7 @@ def run_create(cur, database_engine, *args, **kwargs):
"rows_inserted": 0,
"have_added_indexes": False,
}
progress_json = simplejson.dumps(progress)
progress_json = json.dumps(progress)

sql = (
"INSERT into background_updates (update_name, progress_json)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
# 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
import logging

import simplejson

from synapse.storage.prepare_database import get_statements

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -45,7 +43,7 @@ def run_create(cur, database_engine, *args, **kwargs):
"max_stream_id_exclusive": max_stream_id + 1,
"rows_inserted": 0,
}
progress_json = simplejson.dumps(progress)
progress_json = json.dumps(progress)

sql = (
"INSERT into background_updates (update_name, progress_json)"
Expand Down

0 comments on commit bca03f7

Please sign in to comment.