Skip to content
This repository was archived by the owner on Jan 1, 2026. It is now read-only.

Commit 2aa73f1

Browse files
committed
Switch from FileNotFoundError to more generic IOError for compatibility with Python 2.7.
1 parent 6de947a commit 2aa73f1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

cppcheck_junit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def parse_cppcheck(file_name):
5656
Dict[str, List[CppcheckError]]: Parsed errors grouped by file name.
5757
5858
Raises:
59-
FileNotFoundError: If file_name does not exist.
59+
IOError: If file_name does not exist (More specifically, FileNotFoundError on Python 3).
6060
xml.etree.ElementTree.ParseError: If file_name is not a valid XML file.
6161
ValueError: If unsupported Cppcheck XML version.
6262
"""
@@ -129,7 +129,7 @@ def main():
129129
except ValueError as e:
130130
print(str(e))
131131
return EXIT_FAILURE
132-
except FileNotFoundError as e:
132+
except IOError as e:
133133
print(str(e))
134134
return EXIT_FAILURE
135135
except ElementTree.ParseError as e:

test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_xml_version_1(self):
5757
parse_cppcheck('tests/cppcheck-out-bad-xml-version-1.xml')
5858

5959
def test_file_not_found(self):
60-
with self.assertRaises(FileNotFoundError):
60+
with self.assertRaises(IOError):
6161
parse_cppcheck('tests/file_does_not_exist.xml')
6262

6363
def test_malformed(self):

0 commit comments

Comments
 (0)