diff options
author | Amber Brown <hawkowl@atleastfornow.net> | 2018-08-31 00:19:58 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-31 00:19:58 +1000 |
commit | 14e4d4f4bf894f4e70118e03f4f4575e1eb6dab6 (patch) | |
tree | 1c7ba21ab2ebe5dbf4c7c15b0b89376fda865c31 /synapse/storage/pusher.py | |
parent | Merge pull request #3764 from matrix-org/rav/close_db_conn_after_init (diff) | |
download | synapse-14e4d4f4bf894f4e70118e03f4f4575e1eb6dab6.tar.xz |
Port storage/ to Python 3 (#3725)
Diffstat (limited to 'synapse/storage/pusher.py')
-rw-r--r-- | synapse/storage/pusher.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/synapse/storage/pusher.py b/synapse/storage/pusher.py index 8443bd4c1b..c7987bfcdd 100644 --- a/synapse/storage/pusher.py +++ b/synapse/storage/pusher.py @@ -15,7 +15,8 @@ # limitations under the License. import logging -import types + +import six from canonicaljson import encode_canonical_json, json @@ -27,6 +28,11 @@ from ._base import SQLBaseStore logger = logging.getLogger(__name__) +if six.PY2: + db_binary_type = buffer +else: + db_binary_type = memoryview + class PusherWorkerStore(SQLBaseStore): def _decode_pushers_rows(self, rows): @@ -34,18 +40,18 @@ class PusherWorkerStore(SQLBaseStore): dataJson = r['data'] r['data'] = None try: - if isinstance(dataJson, types.BufferType): + if isinstance(dataJson, db_binary_type): dataJson = str(dataJson).decode("UTF8") r['data'] = json.loads(dataJson) except Exception as e: logger.warn( "Invalid JSON in data for pusher %d: %s, %s", - r['id'], dataJson, e.message, + r['id'], dataJson, e.args[0], ) pass - if isinstance(r['pushkey'], types.BufferType): + if isinstance(r['pushkey'], db_binary_type): r['pushkey'] = str(r['pushkey']).decode("UTF8") return rows |