diff --git a/sourmash/signature.py b/sourmash/signature.py index 1ee5b48c3b..df802726ae 100644 --- a/sourmash/signature.py +++ b/sourmash/signature.py @@ -14,6 +14,7 @@ from ._minhash import to_bytes from ._lowlevel import ffi, lib from .utils import RustObject, rustcall, decode_str +from ._compat import PY2 SIGNATURE_VERSION = 0.4 @@ -200,6 +201,12 @@ def _detect_input_type(data): try: if data.find("sourmash_signature") > 0: return SigInput.BUFFER + elif PY2: + try: + if data.startswith(b'\x1F\x8B'): # gzip compressed + return SigInput.BUFFER + except UnicodeDecodeError: + pass except TypeError: if data.find(b"sourmash_signature") > 0: return SigInput.BUFFER @@ -271,7 +278,7 @@ def load_signatures( ) if input_type == SigInput.BUFFER: - if hasattr(data, "encode"): + if hasattr(data, "encode") and not PY2: data = data.encode("utf-8") sigs_ptr = rustcall(