]> granicus.if.org Git - python/commitdiff
Merged revisions 75935 via svnmerge from
authorLars Gustäbel <lars@gustaebel.de>
Thu, 29 Oct 2009 09:39:47 +0000 (09:39 +0000)
committerLars Gustäbel <lars@gustaebel.de>
Thu, 29 Oct 2009 09:39:47 +0000 (09:39 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r75935 | lars.gustaebel | 2009-10-29 10:15:00 +0100 (Thu, 29 Oct 2009) | 3 lines

  Issue #4750: Store the basename of the original filename in
  the gzip FNAME header as required by RFC 1952.
........

Lib/gzip.py
Misc/NEWS

index 983e0cee07f0fc8be648b9991ef60c31b14d3285..08f9da5a5a9574d95a64cfd1e4bcc8a7d41163e1 100644 (file)
@@ -5,7 +5,7 @@ but random access is not allowed."""
 
 # based on Andrew Kuchling's minigzip.py distributed with the zlib module
 
-import struct, sys, time
+import struct, sys, time, os
 import zlib
 import builtins
 
@@ -158,7 +158,8 @@ class GzipFile:
         try:
             # RFC 1952 requires the FNAME field to be Latin-1. Do not
             # include filenames that cannot be represented that way.
-            fname = self.name.encode('latin-1')
+            fname = os.path.basename(self.name)
+            fname = fname.encode('latin-1')
             if fname.endswith(b'.gz'):
                 fname = fname[:-3]
         except UnicodeEncodeError:
index 030430a9fd89b444ffd1e5dee7b0347cea116d39..a53b28cfc5e1c08337a97e5a420c2e8f700359b8 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -120,6 +120,9 @@ C-API
 Library
 -------
 
+- Issue #4750: Store the basename of the original filename in the gzip FNAME
+  header as required by RFC 1952.
+
 - Issue #1180: Added a new global option to ignore ~/.pydistutils.cfg in
   Distutils.