[Python-checkins] r65514 - python/trunk/Lib/tarfile.py

brett.cannon python-checkins at python.org
Mon Aug 4 23:23:07 CEST 2008


Author: brett.cannon
Date: Mon Aug  4 23:23:07 2008
New Revision: 65514

Log:
Remove a dict.has_key() and list.sort(cmp=) usage from tarfile to silence
warnings under -3.


Modified:
   python/trunk/Lib/tarfile.py

Modified: python/trunk/Lib/tarfile.py
==============================================================================
--- python/trunk/Lib/tarfile.py	(original)
+++ python/trunk/Lib/tarfile.py	Mon Aug  4 23:23:07 2008
@@ -51,6 +51,7 @@
 import struct
 import copy
 import re
+import operator
 
 if sys.platform == 'mac':
     # This module needs work for MacOS9, especially in the area of pathname
@@ -1401,7 +1402,7 @@
             next._apply_pax_info(pax_headers, tarfile.encoding, tarfile.errors)
             next.offset = self.offset
 
-            if pax_headers.has_key("size"):
+            if "size" in pax_headers:
                 # If the extended header replaces the size field,
                 # we need to recalculate the offset where the next
                 # header starts.
@@ -2027,7 +2028,7 @@
             self.extract(tarinfo, path)
 
         # Reverse sort directories.
-        directories.sort(lambda a, b: cmp(a.name, b.name))
+        directories.sort(key=operator.attrgetter('name'))
         directories.reverse()
 
         # Set correct owner, mtime and filemode on directories.


More information about the Python-checkins mailing list