Skip to content

Commit

Permalink
Replace imghdr with Pillow's PIL (#1680)
Browse files Browse the repository at this point in the history
  • Loading branch information
ABizzinotto committed Jun 29, 2023
1 parent 93eb05f commit 063ce1a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ parso==0.8.3
# via jedi
pickleshare==0.7.5
# via ipython
pillow==9.5.0
# via jira (setup.cfg)
pluggy==1.0.0
# via pytest
prompt-toolkit==3.0.38
Expand Down
4 changes: 2 additions & 2 deletions jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import copy
import datetime
import hashlib
import imghdr
import json
import logging as _logging
import mimetypes
Expand Down Expand Up @@ -42,6 +41,7 @@

import requests
from packaging.version import parse as parse_version
from PIL import Image
from requests import Response
from requests.auth import AuthBase
from requests.structures import CaseInsensitiveDict
Expand Down Expand Up @@ -3919,7 +3919,7 @@ def _get_mime_type(self, buff: bytes) -> str | None:
if self._magic is not None:
return self._magic.id_buffer(buff)
try:
return mimetypes.guess_type("f." + str(imghdr.what(0, buff)))[0]
return mimetypes.guess_type("f." + Image.open(buff).format)[0]
except (OSError, TypeError):
self.log.warning(
"Couldn't detect content type of avatar image"
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ zip_safe = False
install_requires =
defusedxml
packaging
Pillow>=2.1.0
requests-oauthlib>=1.1.0
requests>=2.10.0
requests_toolbelt
Expand Down

0 comments on commit 063ce1a

Please sign in to comment.