Skip to content

Commit

Permalink
sigh, py2...
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed Apr 27, 2020
1 parent 71449e2 commit 0bff7d7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sourmash/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 0bff7d7

Please sign in to comment.