[PATCH] Do not format flags if no version is passed to formatRequire

Ville Skyttä <[email protected]>
Newsgroups gmane.linux.rpm.yum
Message-ID <[email protected]>
Hello,

This patch avoids weird output (e.g. "foo <=") if for some reason name and 
flags but no version get passed to formatRequire().

_______________________________________________
Yum mailing list
[email protected]
http://lists.baseurl.org/mailman/listinfo/yum
0004-Do-not-format-flags-if-no-version-is-passed-to-forma.patch (text/x-patch, 1.1 KB)
From 09a5e846af622e70836bd81507e94c6456ceefe6 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ville=20Skytt=C3=A4?= <[email protected]>
Date: Sun, 21 Jun 2009 23:11:01 +0300
Subject: [PATCH] Do not format flags if no version is passed to formatRequire.

---
 rpmUtils/miscutils.py |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/rpmUtils/miscutils.py b/rpmUtils/miscutils.py
index 5b792a0..9d94e06 100644
--- a/rpmUtils/miscutils.py
+++ b/rpmUtils/miscutils.py
@@ -370,7 +370,7 @@ def rpm2cpio(fdno, out=sys.stdout, bufsize=2048):
 def formatRequire (name, version, flags):
     s = name
     
-    if flags:
+    if flags and version:
         if flags & (rpm.RPMSENSE_LESS | rpm.RPMSENSE_GREATER |
                     rpm.RPMSENSE_EQUAL):
             s = s + " "
@@ -380,8 +380,7 @@ def formatRequire (name, version, flags):
                 s = s + ">"
             if flags & rpm.RPMSENSE_EQUAL:
                 s = s + "="
-            if version:
-                s = "%s %s" %(s, version)
+            s = "%s %s" % (s, version)
     return s
     
 def flagToString(flags):
-- 
1.6.0.6
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.