aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2018-06-21 12:52:20 +0100
committerBryn M. Reeves <bmr@redhat.com>2018-06-21 12:52:20 +0100
commita05905e41dd4486669858ea913f48803e1bc5614 (patch)
tree295cd5e54326adadca11621ded9c697e9483372d
parent40295a36127915b344bbf0f69399a3739ab5e2cd (diff)
downloadsos-a05905e41dd4486669858ea913f48803e1bc5614.tar.gz
[sosreport] handle OSError in XmlReport.report()
The XmlReport class in sos.sosreport traverses the list of plugins and prepares a report including each collected file. The access to the file is wrapped in an except block but the recent change to pycodestyle modified this from a 'naked' except into a 'except IOError' block. Attempting to open a non-existent path yields an IOError, however attempting to stat a non-existent path (or a dangling symlink without lstat()) yields OSError: # ln -s foo qux # cat qux cat: qux: No such file or directory >>> os.stat("/foo/qux") Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: [Errno 2] No such file or directory: '/foo/qux' Catch both exception classes in this method. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/sosreport.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py
index f47918fe..b37989b0 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -1131,7 +1131,7 @@ class SoSReport(object):
try:
self.xml_report.add_file(oneFile["srcpath"],
os.stat(oneFile["srcpath"]))
- except IOError:
+ except (OSError, IOError):
pass
try:
self.xml_report.serialize_to_file(os.path.join(self.rptdir,