From 59115aa7c9488baae1b706f077dcd84a558c0097 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 4 May 2013 15:12:55 +0300 Subject: [PATCH] Issue #16316: mimetypes now recognizes the .xz and .txz (.tar.xz) extensions. --- Lib/mimetypes.py | 2 ++ Lib/test/test_mimetypes.py | 2 ++ Misc/NEWS | 2 ++ 3 files changed, 6 insertions(+) diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index 3f0bd0e7198..2872ee4245c 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -378,12 +378,14 @@ def _default_mime_types(): '.taz': '.tar.gz', '.tz': '.tar.gz', '.tbz2': '.tar.bz2', + '.txz': '.tar.xz', } encodings_map = { '.gz': 'gzip', '.Z': 'compress', '.bz2': 'bzip2', + '.xz': 'xz', } # Before adding new types, make sure they are either registered with IANA, diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index 91da28927dc..593fdb0a424 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -22,6 +22,8 @@ class MimeTypesTestCase(unittest.TestCase): eq(self.db.guess_type("foo.tgz"), ("application/x-tar", "gzip")) eq(self.db.guess_type("foo.tar.gz"), ("application/x-tar", "gzip")) eq(self.db.guess_type("foo.tar.Z"), ("application/x-tar", "compress")) + eq(self.db.guess_type("foo.tar.bz2"), ("application/x-tar", "bzip2")) + eq(self.db.guess_type("foo.tar.xz"), ("application/x-tar", "xz")) def test_data_urls(self): eq = self.assertEqual diff --git a/Misc/NEWS b/Misc/NEWS index e4a92bf2b49..554278b62e6 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -44,6 +44,8 @@ Core and Builtins Library ------- +- Issue #16316: mimetypes now recognizes the .xz and .txz (.tar.xz) extensions. + - Issue #15902: Fix imp.load_module() accepting None as a file when loading an extension module.