Merge pull request #5403 from jdufresne/unused-content

Remove unused argument, content, from guess_mimetype
This commit is contained in:
Takeshi KOMIYA 2018-09-10 20:43:24 +09:00 committed by GitHub
commit 908f3a2fcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,7 @@ from __future__ import absolute_import
import base64 import base64
import imghdr import imghdr
import warnings
from collections import OrderedDict from collections import OrderedDict
from os import path from os import path
from typing import NamedTuple from typing import NamedTuple
@ -19,6 +20,8 @@ from typing import NamedTuple
import imagesize import imagesize
from six import PY3, BytesIO, iteritems from six import PY3, BytesIO, iteritems
from sphinx.deprecation import RemovedInSphinx30Warning
try: try:
from PIL import Image # check for the Python Imaging Library from PIL import Image # check for the Python Imaging Library
except ImportError: except ImportError:
@ -83,6 +86,8 @@ def guess_mimetype(filename='', content=None, default=None):
if ext in mime_suffixes: if ext in mime_suffixes:
return mime_suffixes[ext] return mime_suffixes[ext]
elif content: elif content:
warnings.warn('The content argument of guess_mimetype() is deprecated.',
RemovedInSphinx30Warning)
return guess_mimetype_for_stream(BytesIO(content), default=default) return guess_mimetype_for_stream(BytesIO(content), default=default)
elif path.exists(filename): elif path.exists(filename):
with open(filename, 'rb') as f: with open(filename, 'rb') as f: