[Yum-devel] [PATCH] Catch error opening repo files

Jeremy Katz katzj at redhat.com
Wed May 13 18:16:37 UTC 2009


Rather than requiring higher level callers to catch the error,
we should catch the error at the low-level when opening the
repo file and turn it into a RepoMDError.  Related to
rh bz#500526
---
 yum/repoMDObject.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/yum/repoMDObject.py b/yum/repoMDObject.py
index 298d369..37f10f0 100755
--- a/yum/repoMDObject.py
+++ b/yum/repoMDObject.py
@@ -81,7 +81,10 @@ class RepoMD:
         
         if type(srcfile) in types.StringTypes:
             # srcfile is a filename string
-            infile = open(srcfile, 'rt')
+            try:
+                infile = open(srcfile, 'rt')
+            except IOError:
+                raise RepoMDError, "Unable to open %s" %(srcfile,)
         else:
             # srcfile is a file object
             infile = srcfile
-- 
1.6.2.2



More information about the Yum-devel mailing list