summary refs log tree commit diff
path: root/synapse/util
diff options
context:
space:
mode:
authorAdrian Tschira <nota@notafile.com>2018-05-24 20:52:56 +0200
committerAdrian Tschira <nota@notafile.com>2018-05-24 20:55:08 +0200
commitdd068ca9792e7f4a51690b91262131b5dae80455 (patch)
tree3a979667f0fc25653d3eb428bec23f4832085a4e /synapse/util
parentMerge pull request #3278 from NotAFile/py3-storage-base (diff)
downloadsynapse-dd068ca9792e7f4a51690b91262131b5dae80455.tar.xz
remaining isintance fixes
Signed-off-by: Adrian Tschira <nota@notafile.com>
Diffstat (limited to 'synapse/util')
-rw-r--r--synapse/util/caches/descriptors.py12
-rw-r--r--synapse/util/frozenutils.py5
2 files changed, 11 insertions, 6 deletions
diff --git a/synapse/util/caches/descriptors.py b/synapse/util/caches/descriptors.py
index 68285a7594..b595cd6164 100644
--- a/synapse/util/caches/descriptors.py
+++ b/synapse/util/caches/descriptors.py
@@ -31,6 +31,9 @@ import functools
 import inspect
 import threading
 
+from six import string_types, itervalues
+import six
+
 
 logger = logging.getLogger(__name__)
 
@@ -205,7 +208,7 @@ class Cache(object):
     def invalidate_all(self):
         self.check_thread()
         self.cache.clear()
-        for entry in self._pending_deferred_cache.itervalues():
+        for entry in itervalues(self._pending_deferred_cache):
             entry.invalidate()
         self._pending_deferred_cache.clear()
 
@@ -392,9 +395,10 @@ class CacheDescriptor(_CacheDescriptorBase):
 
                 ret.addErrback(onErr)
 
-                # If our cache_key is a string, try to convert to ascii to save
-                # a bit of space in large caches
-                if isinstance(cache_key, basestring):
+                # If our cache_key is a string on py2, try to convert to ascii
+                # to save a bit of space in large caches. Py3 does this
+                # internally automatically.
+                if six.PY2 and isinstance(cache_key, string_types):
                     cache_key = to_ascii(cache_key)
 
                 result_d = ObservableDeferred(ret, consumeErrors=True)
diff --git a/synapse/util/frozenutils.py b/synapse/util/frozenutils.py
index f497b51f4a..4cd0566f4f 100644
--- a/synapse/util/frozenutils.py
+++ b/synapse/util/frozenutils.py
@@ -16,6 +16,7 @@
 from frozendict import frozendict
 import simplejson as json
 
+from six import string_types
 
 def freeze(o):
     t = type(o)
@@ -25,7 +26,7 @@ def freeze(o):
     if t is frozendict:
         return o
 
-    if t is str or t is unicode:
+    if isinstance(t, string_types):
         return o
 
     try:
@@ -41,7 +42,7 @@ def unfreeze(o):
     if t is dict or t is frozendict:
         return dict({k: unfreeze(v) for k, v in o.items()})
 
-    if t is str or t is unicode:
+    if isinstance(t, string_types):
         return o
 
     try: