summaryrefslogtreecommitdiffstats
path: root/Lib/gzip.py
diff options
context:
space:
mode:
authorLars Gustäbel <lars@gustaebel.de>2009-10-29 09:39:47 (GMT)
committerLars Gustäbel <lars@gustaebel.de>2009-10-29 09:39:47 (GMT)
commit1440df2fcfa97415d05d6ad2751c606bb0189fcd (patch)
tree742c979a022925bdf293cbf1d0bbe5314530ea50 /Lib/gzip.py
parent2ee28c906faf9027b99225c96ef54d02d7625e54 (diff)
downloadcpython-1440df2fcfa97415d05d6ad2751c606bb0189fcd.zip
cpython-1440df2fcfa97415d05d6ad2751c606bb0189fcd.tar.gz
cpython-1440df2fcfa97415d05d6ad2751c606bb0189fcd.tar.bz2
Merged revisions 75935 via svnmerge from
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. ........
Diffstat (limited to 'Lib/gzip.py')
-rw-r--r--Lib/gzip.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py
index 983e0ce..08f9da5 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -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: