mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
bpo-41048: mimetypes should read the rule file using UTF-8, not the locale encoding (GH-20998)
This commit is contained in:
parent
e4f1fe6edb
commit
7f569c9bc0
4 changed files with 16 additions and 1 deletions
|
|
@ -67,6 +67,18 @@ class MimeTypesTestCase(unittest.TestCase):
|
|||
mime_dict = mimetypes.read_mime_types(file)
|
||||
eq(mime_dict[".pyunit"], "x-application/x-unittest")
|
||||
|
||||
# bpo-41048: read_mime_types should read the rule file with 'utf-8' encoding.
|
||||
# Not with locale encoding. _bootlocale has been imported because io.open(...)
|
||||
# uses it.
|
||||
with support.temp_dir() as directory:
|
||||
data = "application/no-mans-land Fran\u00E7ais"
|
||||
file = pathlib.Path(directory, "sample.mimetype")
|
||||
file.write_text(data, encoding='utf-8')
|
||||
import _bootlocale
|
||||
with support.swap_attr(_bootlocale, 'getpreferredencoding', lambda do_setlocale=True: 'ASCII'):
|
||||
mime_dict = mimetypes.read_mime_types(file)
|
||||
eq(mime_dict[".Français"], "application/no-mans-land")
|
||||
|
||||
def test_non_standard_types(self):
|
||||
eq = self.assertEqual
|
||||
# First try strict
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue