Issue #13025: mimetypes is now reading MIME types using the UTF-8 encoding,
instead of the locale encoding.
This commit is contained in:
parent
c1f32ca0ad
commit
82ac9bcdb3
|
@ -199,7 +199,7 @@ class MimeTypes:
|
||||||
list of standard types, else to the list of non-standard
|
list of standard types, else to the list of non-standard
|
||||||
types.
|
types.
|
||||||
"""
|
"""
|
||||||
with open(filename) as fp:
|
with open(filename, encoding='utf-8') as fp:
|
||||||
self.readfp(fp, strict)
|
self.readfp(fp, strict)
|
||||||
|
|
||||||
def readfp(self, fp, strict=True):
|
def readfp(self, fp, strict=True):
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,8 @@
|
||||||
import mimetypes
|
|
||||||
import io
|
import io
|
||||||
import unittest
|
import locale
|
||||||
|
import mimetypes
|
||||||
import sys
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
from test import support
|
from test import support
|
||||||
|
|
||||||
|
@ -62,6 +63,18 @@ class MimeTypesTestCase(unittest.TestCase):
|
||||||
all = self.db.guess_all_extensions('image/jpg', strict=True)
|
all = self.db.guess_all_extensions('image/jpg', strict=True)
|
||||||
eq(all, [])
|
eq(all, [])
|
||||||
|
|
||||||
|
def test_encoding(self):
|
||||||
|
getpreferredencoding = locale.getpreferredencoding
|
||||||
|
self.addCleanup(setattr, locale, 'getpreferredencoding',
|
||||||
|
getpreferredencoding)
|
||||||
|
locale.getpreferredencoding = lambda: 'ascii'
|
||||||
|
|
||||||
|
filename = support.findfile("mime.types")
|
||||||
|
mimes = mimetypes.MimeTypes([filename])
|
||||||
|
exts = mimes.guess_all_extensions('application/vnd.geocube+xml',
|
||||||
|
strict=True)
|
||||||
|
self.assertEqual(exts, ['.g3', '.g\xb3'])
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(sys.platform.startswith("win"), "Windows only")
|
@unittest.skipUnless(sys.platform.startswith("win"), "Windows only")
|
||||||
class Win32MimeTypesTestCase(unittest.TestCase):
|
class Win32MimeTypesTestCase(unittest.TestCase):
|
||||||
|
|
|
@ -43,6 +43,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #13025: mimetypes is now reading MIME types using the UTF-8 encoding,
|
||||||
|
instead of the locale encoding.
|
||||||
|
|
||||||
- Issue #10653: On Windows, use strftime() instead of wcsftime() because
|
- Issue #10653: On Windows, use strftime() instead of wcsftime() because
|
||||||
wcsftime() doesn't format time zone correctly.
|
wcsftime() doesn't format time zone correctly.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue