From 3a99494a876290350e7e4eb7b189bd8b308566ce Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 2 Dec 2020 07:59:41 +0100 Subject: items: Catch all YAML errors --- rtemsspec/items.py | 4 ++-- rtemsspec/tests/test_items_itemcache.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rtemsspec/items.py b/rtemsspec/items.py index 12ecfb42..2bbf0848 100644 --- a/rtemsspec/items.py +++ b/rtemsspec/items.py @@ -495,8 +495,8 @@ def _load_item(path: str, uid: str) -> Any: with open(path, "r") as src: try: data = yaml.safe_load(src.read()) - except yaml.parser.ParserError as err: - msg = ("YAML parser error while loading specification item file " + except yaml.YAMLError as err: + msg = ("YAML error while loading specification item file " f"'{path}': {str(err)}") raise IOError(msg) from err data["_file"] = os.path.abspath(path) diff --git a/rtemsspec/tests/test_items_itemcache.py b/rtemsspec/tests/test_items_itemcache.py index 4331b335..d90b1e04 100644 --- a/rtemsspec/tests/test_items_itemcache.py +++ b/rtemsspec/tests/test_items_itemcache.py @@ -84,10 +84,10 @@ def test_load_link_error(tmpdir): ItemCache(config) -def test_load_parser_error(tmpdir): +def test_load_yaml_error(tmpdir): config = create_item_cache_config_and_copy_spec(tmpdir, "spec-item-cache-3") - match = r"""YAML parser error while loading specification item file '.*invalid.yml': while parsing a block mapping + match = r"""YAML error while loading specification item file '.*invalid.yml': while parsing a block mapping expected , but found ':' in "", line 1, column 1: : -- cgit v1.2.3