Skip to content

Commit

Permalink
Deal with py3 travis vs. local diffs in magic
Browse files Browse the repository at this point in the history
  • Loading branch information
zimeon committed Jul 26, 2016
1 parent 0c6d7b8 commit 00d0d40
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion iiif/manipulator_netpbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import glob
import magic
import subprocess
from builtins import bytes

from .error import IIIFError
from .request import IIIFRequest
Expand Down Expand Up @@ -247,7 +248,10 @@ def file_type(self, file):
Returns 'png' or 'jpg' on success, nothing on failure.
"""
try:
magic_text = magic.from_file(file).decode('utf-8')
magic_text = magic.from_file(file)
if (isinstance(magic_text, bytes)):
# In python2 and travis python3 (?!) decode to get unicode string
magic_text = magic_text.decode('utf-8')
except (TypeError, IOError):
return
if (re.search('PNG image data', magic_text)):
Expand Down

0 comments on commit 00d0d40

Please sign in to comment.