]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Remove a dict.has_key() and list.sort(cmp=) usage from tarfile to silence
authorBrett Cannon <bcannon@gmail.com>
Mon, 4 Aug 2008 21:23:07 +0000 (21:23 +0000)
committerBrett Cannon <bcannon@gmail.com>
Mon, 4 Aug 2008 21:23:07 +0000 (21:23 +0000)
warnings under -3.

Lib/tarfile.py

index 85abcd8d85020619a34528dd20d9e6ffdd7a6ab6..ab74cc59253aa07e49d5e0a7941b15e736487d8b 100644 (file)
@@ -51,6 +51,7 @@ import time
 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 @@ class TarInfo(object):
             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 @@ class TarFile(object):
             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.