[Python-checkins] cpython: Issue #16316: mimetypes now recognizes the .xz and .txz (.tar.xz) extensions.

nadeem.vawda python-checkins at python.org
Sun Oct 28 14:53:05 CET 2012


http://hg.python.org/cpython/rev/a3ba5fe9bfd3
changeset:   80034:a3ba5fe9bfd3
user:        Nadeem Vawda <nadeem.vawda at gmail.com>
date:        Sun Oct 28 14:52:34 2012 +0100
summary:
  Issue #16316: mimetypes now recognizes the .xz and .txz (.tar.xz) extensions.

Patch by Serhiy Storchaka.

files:
  Lib/mimetypes.py           |  2 ++
  Lib/test/test_mimetypes.py |  2 ++
  Misc/NEWS                  |  3 +++
  3 files changed, 7 insertions(+), 0 deletions(-)


diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py
--- a/Lib/mimetypes.py
+++ b/Lib/mimetypes.py
@@ -378,12 +378,14 @@
         '.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
--- a/Lib/test/test_mimetypes.py
+++ b/Lib/test/test_mimetypes.py
@@ -22,6 +22,8 @@
         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
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -62,6 +62,9 @@
 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.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list