]> granicus.if.org Git - python/commitdiff
Issue #4750: Store the basename of the original filename in
authorLars Gustäbel <lars@gustaebel.de>
Thu, 29 Oct 2009 09:15:00 +0000 (09:15 +0000)
committerLars Gustäbel <lars@gustaebel.de>
Thu, 29 Oct 2009 09:15:00 +0000 (09:15 +0000)
the gzip FNAME header as required by RFC 1952.

Lib/gzip.py
Misc/NEWS

index 9605d5d0972a5df780857fc5a8cc2f7bc2821e41..8d71cd383f72542c1f516bdca11a6032e9cd9155 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 __builtin__
 
@@ -143,7 +143,7 @@ class GzipFile:
     def _write_gzip_header(self):
         self.fileobj.write('\037\213')             # magic header
         self.fileobj.write('\010')                 # compression method
-        fname = self.name
+        fname = os.path.basename(self.name)
         if fname.endswith(".gz"):
             fname = fname[:-3]
         flags = 0
index 24cb7b3b377aac760b327ac9e9ab2f2a60b5919e..2e2f822b12d87a0944fc87fad7e425c9a2b4b99e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -427,6 +427,9 @@ Core and Builtins
 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.