Igor Gnatenko 7cf326
From 49197c930bb6090d0fca4089ea75ec9d10e62f99 Mon Sep 17 00:00:00 2001
Igor Gnatenko 7cf326
From: =?UTF-8?q?Neal=20Gompa=20=28=E3=83=8B=E3=83=BC=E3=83=AB=E3=83=BB?=
Igor Gnatenko 7cf326
 =?UTF-8?q?=E3=82=B3=E3=82=99=E3=83=B3=E3=83=8F=E3=82=9A=29?=
Igor Gnatenko 7cf326
 <ngompa13@gmail.com>
Igor Gnatenko 7cf326
Date: Sat, 20 Aug 2016 11:01:06 -0400
Igor Gnatenko 7cf326
Subject: [PATCH 1/3] pythondistdeps.py: skip distribution metadata if there is
Igor Gnatenko 7cf326
 no version
Igor Gnatenko 7cf326
Igor Gnatenko 7cf326
For example, reading .egg-link using pkg_resources.Distribution returns
Igor Gnatenko 7cf326
actual metadata, but it does not contain version. It returns traceback like:
Igor Gnatenko 7cf326
Igor Gnatenko 7cf326
File "/usr/lib/rpm/pythondistdeps.py", line 113, in <module>
Igor Gnatenko 7cf326
    pyver_major = dist.py_version.split('.')[0]
Igor Gnatenko 7cf326
AttributeError: 'NoneType' object has no attribute 'split'
Igor Gnatenko 7cf326
Traceback (most recent call last):
Igor Gnatenko 7cf326
  File "/usr/lib/rpm/pythondistdeps.py", line 113, in <module>
Igor Gnatenko 7cf326
    pyver_major = dist.py_version.split('.')[0]
Igor Gnatenko 7cf326
AttributeError: 'NoneType' object has no attribute 'split'
Igor Gnatenko 7cf326
Igor Gnatenko 7cf326
Let's just skip such errors as we can't do much about that.
Igor Gnatenko 7cf326
Igor Gnatenko 7cf326
Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1368673
Igor Gnatenko 7cf326
Reported-and-tested-by: Igor Gnatenko <ignatenko@redhat.com>
Igor Gnatenko 7cf326
---
Igor Gnatenko 7cf326
 scripts/pythondistdeps.py | 3 +++
Igor Gnatenko 7cf326
 1 file changed, 3 insertions(+)
Igor Gnatenko 7cf326
Igor Gnatenko 7cf326
diff --git a/scripts/pythondistdeps.py b/scripts/pythondistdeps.py
Igor Gnatenko 7cf326
index 8a2f43d..54905c3 100755
Igor Gnatenko 7cf326
--- a/scripts/pythondistdeps.py
Igor Gnatenko 7cf326
+++ b/scripts/pythondistdeps.py
Igor Gnatenko 7cf326
@@ -108,6 +108,9 @@ for f in files:
Igor Gnatenko 7cf326
             path_item = f
Igor Gnatenko 7cf326
             metadata = FileMetadata(f)
Igor Gnatenko 7cf326
         dist = Distribution.from_location(path_item, dist_name, metadata)
Igor Gnatenko 7cf326
+        # Check if py_version is defined in the file
Igor Gnatenko 7cf326
+        if not dist.py_version:
Igor Gnatenko 7cf326
+            continue
Igor Gnatenko 7cf326
         if (Provides_PyMajorVer_Variant or legacy_Provides or legacy) and Provides:
Igor Gnatenko 7cf326
             # Get the Python major version
Igor Gnatenko 7cf326
             pyver_major = dist.py_version.split('.')[0]
Igor Gnatenko 7cf326
-- 
Igor Gnatenko 7cf326
2.9.3
Igor Gnatenko 7cf326