Skip to content

Commit 063ce1a

Browse files
authored
Replace imghdr with Pillow's PIL (#1680)
1 parent 93eb05f commit 063ce1a

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

constraints.txt

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ parso==0.8.3
9999
# via jedi
100100
pickleshare==0.7.5
101101
# via ipython
102+
pillow==9.5.0
103+
# via jira (setup.cfg)
102104
pluggy==1.0.0
103105
# via pytest
104106
prompt-toolkit==3.0.38

jira/client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import copy
1212
import datetime
1313
import hashlib
14-
import imghdr
1514
import json
1615
import logging as _logging
1716
import mimetypes
@@ -42,6 +41,7 @@
4241

4342
import requests
4443
from packaging.version import parse as parse_version
44+
from PIL import Image
4545
from requests import Response
4646
from requests.auth import AuthBase
4747
from requests.structures import CaseInsensitiveDict
@@ -3919,7 +3919,7 @@ def _get_mime_type(self, buff: bytes) -> str | None:
39193919
if self._magic is not None:
39203920
return self._magic.id_buffer(buff)
39213921
try:
3922-
return mimetypes.guess_type("f." + str(imghdr.what(0, buff)))[0]
3922+
return mimetypes.guess_type("f." + Image.open(buff).format)[0]
39233923
except (OSError, TypeError):
39243924
self.log.warning(
39253925
"Couldn't detect content type of avatar image"

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ zip_safe = False
5151
install_requires =
5252
defusedxml
5353
packaging
54+
Pillow>=2.1.0
5455
requests-oauthlib>=1.1.0
5556
requests>=2.10.0
5657
requests_toolbelt

0 commit comments

Comments
 (0)