]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blobdiff - src/allmydata/__init__.py
Avoid spurious errors when an imported version is consistent with pkg_resources
[tahoe-lafs/tahoe-lafs.git] / src / allmydata / __init__.py
index 0b0c5f816cc392920822cc1c496bf74cd15b812c..fa512a13a9860a1bd84986e7bbe0d0ee20f17487 100644 (file)
@@ -146,7 +146,8 @@ def get_platform():
 from allmydata.util import verlib
 def normalized_version(verstr, what=None):
     try:
-        return verlib.NormalizedVersion(verlib.suggest_normalized_version(verstr))
+        suggested = verlib.suggest_normalized_version(verstr) or verstr
+        return verlib.NormalizedVersion(suggested)
     except (StandardError, verlib.IrrationalVersionError):
         cls, value, trace = sys.exc_info()
         raise PackagingError, ("could not parse %s due to %s: %s"
@@ -351,6 +352,11 @@ def cross_check(pkg_resources_vers_and_locs, imported_vers_and_locs_list):
                               % (name, pr_ver, pr_loc, imp_comment))
                 continue
 
+            # If the pkg_resources version is identical to the imported version, don't attempt
+            # to normalize them, since it is unnecessary and may fail (ticket #2499).
+            if imp_ver != 'unknown' and pr_ver == imp_ver:
+                continue
+
             try:
                 pr_normver = normalized_version(pr_ver)
             except Exception, e: