summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorLars Gustäbel <lars@gustaebel.de>2007-02-13 16:24:00 (GMT)
committerLars Gustäbel <lars@gustaebel.de>2007-02-13 16:24:00 (GMT)
commitf19c1b5e0e753c85f6df8a2dec5f4bb75743fc10 (patch)
tree5768341d75d8e70e4bd5ff158e01372d741ef5bd /Lib
parent5b1a7857023d15a2f51467c765bade1d6f349c5e (diff)
downloadcpython-f19c1b5e0e753c85f6df8a2dec5f4bb75743fc10.zip
cpython-f19c1b5e0e753c85f6df8a2dec5f4bb75743fc10.tar.gz
cpython-f19c1b5e0e753c85f6df8a2dec5f4bb75743fc10.tar.bz2
Strip the '.gz' extension from the filename that is written to the
gzip header.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/gzip.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py
index ea3656f..d85ba2b 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -149,15 +149,18 @@ class GzipFile:
def _write_gzip_header(self):
self.fileobj.write('\037\213') # magic header
self.fileobj.write('\010') # compression method
+ fname = self.name
+ if fname.endswith(".gz"):
+ fname = fname[:-3]
flags = 0
- if self.name:
+ if fname:
flags = FNAME
self.fileobj.write(chr(flags))
write32u(self.fileobj, long(time.time()))
self.fileobj.write('\002')
self.fileobj.write('\377')
- if self.name:
- self.fileobj.write(self.name + '\000')
+ if fname:
+ self.fileobj.write(fname + '\000')
def _init_read(self):
self.crc = zlib.crc32("")