]> granicus.if.org Git - python/commitdiff
Issue #16316: mimetypes now recognizes the .xz and .txz (.tar.xz) extensions.
authorNadeem Vawda <nadeem.vawda@gmail.com>
Sun, 28 Oct 2012 13:52:34 +0000 (14:52 +0100)
committerNadeem Vawda <nadeem.vawda@gmail.com>
Sun, 28 Oct 2012 13:52:34 +0000 (14:52 +0100)
Patch by Serhiy Storchaka.

Lib/mimetypes.py
Lib/test/test_mimetypes.py
Misc/NEWS

index 3f0bd0e71989abe4dfb134e361583c7f0921bbee..2872ee4245cdb4fe17835b0867ca19f6b9b3848b 100644 (file)
@@ -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,
index 91da28927dc9f9523182262bcaf947a3aac805f6..593fdb0a424fad0b069b65c373d39db292d83818 100644 (file)
@@ -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
index ad2530b634f79bf403ee60f00da709cb4d1e470f..13e3669d27e31c06336c85c8bd24b945812db859 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -62,6 +62,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #16316: mimetypes now recognizes the .xz and .txz (.tar.xz) extensions.
+  Patch by Serhiy Storchaka.
+
 - Issue #12890: cgitb no longer prints spurious <p> tags in text
   mode when the logdir option is specified.