Blob Blame History Raw
From 49197c930bb6090d0fca4089ea75ec9d10e62f99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Neal=20Gompa=20=28=E3=83=8B=E3=83=BC=E3=83=AB=E3=83=BB?=
 =?UTF-8?q?=E3=82=B3=E3=82=99=E3=83=B3=E3=83=8F=E3=82=9A=29?=
 <ngompa13@gmail.com>
Date: Sat, 20 Aug 2016 11:01:06 -0400
Subject: [PATCH 1/3] pythondistdeps.py: skip distribution metadata if there is
 no version

For example, reading .egg-link using pkg_resources.Distribution returns
actual metadata, but it does not contain version. It returns traceback like:

File "/usr/lib/rpm/pythondistdeps.py", line 113, in <module>
    pyver_major = dist.py_version.split('.')[0]
AttributeError: 'NoneType' object has no attribute 'split'
Traceback (most recent call last):
  File "/usr/lib/rpm/pythondistdeps.py", line 113, in <module>
    pyver_major = dist.py_version.split('.')[0]
AttributeError: 'NoneType' object has no attribute 'split'

Let's just skip such errors as we can't do much about that.

Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1368673
Reported-and-tested-by: Igor Gnatenko <ignatenko@redhat.com>
---
 scripts/pythondistdeps.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/pythondistdeps.py b/scripts/pythondistdeps.py
index 8a2f43d..54905c3 100755
--- a/scripts/pythondistdeps.py
+++ b/scripts/pythondistdeps.py
@@ -108,6 +108,9 @@ for f in files:
             path_item = f
             metadata = FileMetadata(f)
         dist = Distribution.from_location(path_item, dist_name, metadata)
+        # Check if py_version is defined in the file
+        if not dist.py_version:
+            continue
         if (Provides_PyMajorVer_Variant or legacy_Provides or legacy) and Provides:
             # Get the Python major version
             pyver_major = dist.py_version.split('.')[0]
-- 
2.9.3