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/signatures.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/signatures.py')
-rw-r--r-- | synapse/storage/signatures.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/synapse/storage/signatures.py b/synapse/storage/signatures.py index 9e6eaaa532..25922e5a9c 100644 --- a/synapse/storage/signatures.py +++ b/synapse/storage/signatures.py @@ -14,6 +14,7 @@ # limitations under the License. from twisted.internet import defer +import six from ._base import SQLBaseStore @@ -21,6 +22,13 @@ from unpaddedbase64 import encode_base64 from synapse.crypto.event_signing import compute_event_reference_hash from synapse.util.caches.descriptors import cached, cachedList +# 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 + class SignatureWorkerStore(SQLBaseStore): @cached() @@ -56,7 +64,7 @@ class SignatureWorkerStore(SQLBaseStore): for e_id, h in hashes.items() } - defer.returnValue(hashes.items()) + defer.returnValue(list(hashes.items())) def _get_event_reference_hashes_txn(self, txn, event_id): """Get all the hashes for a given PDU. @@ -91,7 +99,7 @@ class SignatureStore(SignatureWorkerStore): vals.append({ "event_id": event.event_id, "algorithm": ref_alg, - "hash": buffer(ref_hash_bytes), + "hash": db_binary_type(ref_hash_bytes), }) self._simple_insert_many_txn( |