Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace imghdr with Pillow's PIL #1680

Merged
merged 5 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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>=2.1.0
adehad marked this conversation as resolved.
Show resolved Hide resolved
# 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 @@ -3898,7 +3898,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