diff options
author | Amber Brown <hawkowl@atleastfornow.net> | 2018-05-30 12:51:42 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-30 12:51:42 +1000 |
commit | 872cf4351698e9723edd5b58c436087be2986a32 (patch) | |
tree | f4fbbc979dff69f61db5ee66a418915de04d590f /synapse/storage/transactions.py | |
parent | Merge pull request #3281 from NotAFile/py3-six-isinstance (diff) | |
parent | add remaining memoryview changes (diff) | |
download | synapse-872cf4351698e9723edd5b58c436087be2986a32.tar.xz |
Merge pull request #3303 from NotAFile/py3-memoryview
use memoryview in py3
Diffstat (limited to 'synapse/storage/transactions.py')
-rw-r--r-- | synapse/storage/transactions.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/synapse/storage/transactions.py b/synapse/storage/transactions.py index f825264ea9..e485d19b84 100644 --- a/synapse/storage/transactions.py +++ b/synapse/storage/transactions.py @@ -17,6 +17,7 @@ from ._base import SQLBaseStore from synapse.util.caches.descriptors import cached from twisted.internet import defer +import six from canonicaljson import encode_canonical_json @@ -25,6 +26,13 @@ from collections import namedtuple import logging import simplejson as json +# py2 sqlite has buffer hardcoded as only binary type, so we must use it, +# despite being deprecated and removed in favor of memoryview +if six.PY2: + db_binary_type = buffer +else: + db_binary_type = memoryview + logger = logging.getLogger(__name__) @@ -110,7 +118,7 @@ class TransactionStore(SQLBaseStore): "transaction_id": transaction_id, "origin": origin, "response_code": code, - "response_json": buffer(encode_canonical_json(response_dict)), + "response_json": db_binary_type(encode_canonical_json(response_dict)), "ts": self._clock.time_msec(), }, or_ignore=True, |