mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 13:49:22 -05:00
Do not use simplejson in Synapse. (#7800)
This commit is contained in:
parent
ff0680f69d
commit
e7efd8f827
1
changelog.d/7800.misc
Normal file
1
changelog.d/7800.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Switch from simplejson to the standard library json.
|
@ -18,18 +18,11 @@ The VALID_SERVER_COMMANDS and VALID_CLIENT_COMMANDS define which commands are
|
|||||||
allowed to be sent by which side.
|
allowed to be sent by which side.
|
||||||
"""
|
"""
|
||||||
import abc
|
import abc
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
import platform
|
|
||||||
from typing import Tuple, Type
|
from typing import Tuple, Type
|
||||||
|
|
||||||
if platform.python_implementation() == "PyPy":
|
_json_encoder = json.JSONEncoder()
|
||||||
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
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -11,11 +11,9 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import simplejson
|
|
||||||
|
|
||||||
from synapse.storage.engines import PostgresEngine, Sqlite3Engine
|
from synapse.storage.engines import PostgresEngine, Sqlite3Engine
|
||||||
from synapse.storage.prepare_database import get_statements
|
from synapse.storage.prepare_database import get_statements
|
||||||
|
|
||||||
@ -66,7 +64,7 @@ def run_create(cur, database_engine, *args, **kwargs):
|
|||||||
"max_stream_id_exclusive": max_stream_id + 1,
|
"max_stream_id_exclusive": max_stream_id + 1,
|
||||||
"rows_inserted": 0,
|
"rows_inserted": 0,
|
||||||
}
|
}
|
||||||
progress_json = simplejson.dumps(progress)
|
progress_json = json.dumps(progress)
|
||||||
|
|
||||||
sql = (
|
sql = (
|
||||||
"INSERT into background_updates (update_name, progress_json)"
|
"INSERT into background_updates (update_name, progress_json)"
|
||||||
|
@ -11,11 +11,9 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import simplejson
|
|
||||||
|
|
||||||
from synapse.storage.prepare_database import get_statements
|
from synapse.storage.prepare_database import get_statements
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -45,7 +43,7 @@ def run_create(cur, database_engine, *args, **kwargs):
|
|||||||
"max_stream_id_exclusive": max_stream_id + 1,
|
"max_stream_id_exclusive": max_stream_id + 1,
|
||||||
"rows_inserted": 0,
|
"rows_inserted": 0,
|
||||||
}
|
}
|
||||||
progress_json = simplejson.dumps(progress)
|
progress_json = json.dumps(progress)
|
||||||
|
|
||||||
sql = (
|
sql = (
|
||||||
"INSERT into background_updates (update_name, progress_json)"
|
"INSERT into background_updates (update_name, progress_json)"
|
||||||
|
@ -11,11 +11,9 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import simplejson
|
|
||||||
|
|
||||||
from synapse.storage.engines import PostgresEngine
|
from synapse.storage.engines import PostgresEngine
|
||||||
from synapse.storage.prepare_database import get_statements
|
from synapse.storage.prepare_database import get_statements
|
||||||
|
|
||||||
@ -50,7 +48,7 @@ def run_create(cur, database_engine, *args, **kwargs):
|
|||||||
"rows_inserted": 0,
|
"rows_inserted": 0,
|
||||||
"have_added_indexes": False,
|
"have_added_indexes": False,
|
||||||
}
|
}
|
||||||
progress_json = simplejson.dumps(progress)
|
progress_json = json.dumps(progress)
|
||||||
|
|
||||||
sql = (
|
sql = (
|
||||||
"INSERT into background_updates (update_name, progress_json)"
|
"INSERT into background_updates (update_name, progress_json)"
|
||||||
|
@ -11,11 +11,9 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import simplejson
|
|
||||||
|
|
||||||
from synapse.storage.prepare_database import get_statements
|
from synapse.storage.prepare_database import get_statements
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -45,7 +43,7 @@ def run_create(cur, database_engine, *args, **kwargs):
|
|||||||
"max_stream_id_exclusive": max_stream_id + 1,
|
"max_stream_id_exclusive": max_stream_id + 1,
|
||||||
"rows_inserted": 0,
|
"rows_inserted": 0,
|
||||||
}
|
}
|
||||||
progress_json = simplejson.dumps(progress)
|
progress_json = json.dumps(progress)
|
||||||
|
|
||||||
sql = (
|
sql = (
|
||||||
"INSERT into background_updates (update_name, progress_json)"
|
"INSERT into background_updates (update_name, progress_json)"
|
||||||
|
Loading…
Reference in New Issue
Block a user