From c1592465121926ded8994b9ab41a1d7383c4187c Mon Sep 17 00:00:00 2001 From: "Ivan A. Melnikov" Date: Wed, 29 Jan 2014 17:43:32 +0400 Subject: [PATCH] py2rpm: Don't crash when some manifest fields are not defined Make py2rpm handle gracefully (instead of crashing) when authors leave license or homepage fields unspecified in their package manifest. Test case: PuLP==1.5.4 Change-Id: I0b99487afae2e03df24e53e94b02ebddfd9edaf1 --- tools/py2rpm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/py2rpm b/tools/py2rpm index 665ef57b..309b13e8 100755 --- a/tools/py2rpm +++ b/tools/py2rpm @@ -545,9 +545,11 @@ def build_rpm(options, filename): tags.append(("Vendor", "%s <%s>" % (info["author"], info["author-email"]))) tags.append(("Url", info["home-page"])) max_name_len = max(len(tag[0]) for tag in tags) - for tag in tags: - print >> spec_file, "%s:" % tag[0], " " * ( - max_name_len - len(tag[0]) + 1), one_line(tag[1], max_len=-1) + for tag_name, tag_value in tags: + if not tag_value: + tag_value = 'Unknown' + print >> spec_file, "%s:" % tag_name, " " * ( + max_name_len - len(tag_name) + 1), one_line(tag_value, max_len=-1) if rpm_requires: print >> spec_file, rpm_requires if rpm_conflicts: