match_from_list: preserve input in result
authorZac Medico <zmedico@gentoo.org>
Sun, 13 May 2012 09:31:15 +0000 (02:31 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 13 May 2012 09:31:15 +0000 (02:31 -0700)
This fixes an unintended change in behavior from commit
f31320b67c9f593a2a8592e1a4e547f5f641943a.

pym/portage/dep/__init__.py

index 240e2237f39edcc9f80e57272ecb9039c6835ec9..31ec75cf6dd89985de389f4609f4eb5eac54f90e 100644 (file)
@@ -2006,16 +2006,18 @@ def match_from_list(mydep, candidate_list):
 
        elif operator in [">", ">=", "<", "<="]:
                for x in candidate_list:
-                       if not hasattr(x, 'cp'):
+                       if hasattr(x, 'cp'):
+                               pkg = x
+                       else:
                                try:
-                                       x = _pkg_str(remove_slot(x))
+                                       pkg = _pkg_str(remove_slot(x))
                                except InvalidData:
                                        continue
 
-                       if x.cp != mydep.cp:
+                       if pkg.cp != mydep.cp:
                                continue
                        try:
-                               result = vercmp(x.version, mydep.version)
+                               result = vercmp(pkg.version, mydep.version)
                        except ValueError: # pkgcmp may return ValueError during int() conversion
                                writemsg(_("\nInvalid package name: %s\n") % x, noiselevel=-1)
                                raise