mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Correct some unicode/str types to bytes
More explicit and more forward compatible with Python 3.
This commit is contained in:
parent
ffaa528c98
commit
38709af87b
@ -65,7 +65,7 @@ class _TranslationProxy(UserString, object):
|
||||
# for the encoding result
|
||||
|
||||
def encode(self, encoding=None, errors=None): # type: ignore
|
||||
# type: (unicode, unicode) -> str
|
||||
# type: (unicode, unicode) -> bytes
|
||||
if encoding:
|
||||
if errors:
|
||||
return self.data.encode(encoding, errors)
|
||||
|
@ -78,7 +78,7 @@ def guess_mimetype_for_stream(stream, default=None):
|
||||
|
||||
|
||||
def guess_mimetype(filename='', content=None, default=None):
|
||||
# type: (unicode, unicode, unicode) -> unicode
|
||||
# type: (unicode, bytes, unicode) -> unicode
|
||||
_, ext = path.splitext(filename.lower())
|
||||
if ext in mime_suffixes:
|
||||
return mime_suffixes[ext]
|
||||
@ -123,7 +123,7 @@ def parse_data_uri(uri):
|
||||
|
||||
|
||||
def test_svg(h, f):
|
||||
# type: (unicode, IO) -> unicode
|
||||
# type: (bytes, IO) -> unicode
|
||||
"""An additional imghdr library helper; test the header is SVG's or not."""
|
||||
try:
|
||||
if '<svg' in h.decode('utf-8').lower():
|
||||
|
Loading…
Reference in New Issue
Block a user