diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-12-02 07:59:41 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-12-02 08:00:49 +0100 |
commit | 3a99494a876290350e7e4eb7b189bd8b308566ce (patch) | |
tree | 8b6403727213c2f7d3892b7bb94f828f3493e6e6 | |
parent | spec: Clarify rtems_partition_delete() (diff) | |
download | rtems-central-3a99494a876290350e7e4eb7b189bd8b308566ce.tar.bz2 |
items: Catch all YAML errors
-rw-r--r-- | rtemsspec/items.py | 4 | ||||
-rw-r--r-- | 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 <block end>, but found ':' in "<unicode string>", line 1, column 1: : |