[python-debian/master 2/2] arfile.ArFile.extractfile: Fix an incorrect early return.

John Wright jsw at debian.org
Mon Oct 8 08:20:06 UTC 2012


Now it will return a matching member even if it is not the first one in the
archive.  This commit also adds a TODO to investigate either switching that
method to call getmember instead of looping over the memembers, or
deprecating/deleting it if nobody is actually using it.

Thanks to Mika Eloranta for the bug report and patch.

Closes: #689313
---
 debian/changelog     |    3 +++
 lib/debian/arfile.py |   11 +++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index e7c2199..d1abfb1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,9 @@
 python-debian (0.1.22) UNRELEASED; urgency=low
 
   * Acknowledge NMU.  (Thanks for your work, Colin!)
+  * arfile.ArFile.extractfile: Return a matching member even if it is
+    not the first one in the archive.  Thanks to Mika Eloranta for the
+    report and patch. (Closes: #689313)
 
  -- John Wright <jsw at debian.org>  Mon, 08 Oct 2012 00:41:32 -0700
 
diff --git a/lib/debian/arfile.py b/lib/debian/arfile.py
index fe935f3..0df1f68 100644
--- a/lib/debian/arfile.py
+++ b/lib/debian/arfile.py
@@ -134,13 +134,20 @@ class ArFile(object):
         can be specified either as a string (its name) or as a ArMember
         instance. """
 
+        # TODO(jsw): What is the point of this method?  It differs from
+        # getmember in the following ways:
+        #  - It returns the *first* member with the given name instead of the
+        #    last.
+        #  - If member is an ArMember, it uses that ArMember's name as the key.
+        # The former just seems confusing (and this implementation less
+        # efficient than getmember's - probably historical), and I'm having a
+        # hard time seeing the use-case for the latter.
         for m in self.__members:
             if isinstance(member, ArMember) and m.name == member.name:
                 return m
             elif member == m.name:
                 return m
-            else:
-                return None 
+        return None
 
     # container emulation
 
-- 
1.7.2.5




More information about the pkg-python-debian-commits mailing list