Author: lars.gustaebel
Date: Mon Aug 13 11:05:16 2007
New Revision: 56982

Modified:
   python/branches/py3k/Lib/gzip.py
Log:
Retouch my last change after a comment on style from Guido.



Modified: python/branches/py3k/Lib/gzip.py
==============================================================================
--- python/branches/py3k/Lib/gzip.py    (original)
+++ python/branches/py3k/Lib/gzip.py    Mon Aug 13 11:05:16 2007
@@ -149,18 +149,15 @@
     def _write_gzip_header(self):
         self.fileobj.write(b'\037\213')             # magic header
         self.fileobj.write(b'\010')                 # compression method
-        fname = self.name
-        if fname.endswith(".gz"):
-            fname = fname[:-3]
-        flags = 0
-
-        # RFC 1952 requires the FNAME field to be Latin-1. Do not
-        # include filenames that cannot be represented that way.
         try:
-            fname = fname.encode('latin-1')
+            # 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')
+            if fname.endswith(b'.gz'):
+                fname = fname[:-3]
         except UnicodeEncodeError:
-            fname = ''
-
+            fname = b''
+        flags = 0
         if fname:
             flags = FNAME
         self.fileobj.write(chr(flags).encode('latin-1'))
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to