From 7f1dc9faf7be2faaafcbdf862d0fa4e2fffc6aa0 Mon Sep 17 00:00:00 2001 From: Scott Dixon Date: Fri, 10 Jan 2025 12:14:09 -0800 Subject: [PATCH] Fix for #114 This is causing Nunavut 3.0 to become unresponsive if given a bad path. --- pydsdl/__init__.py | 2 +- pydsdl/_dsdl_definition.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pydsdl/__init__.py b/pydsdl/__init__.py index bc71a3e..5f9ac61 100644 --- a/pydsdl/__init__.py +++ b/pydsdl/__init__.py @@ -7,7 +7,7 @@ import sys as _sys from pathlib import Path as _Path -__version__ = "1.22.1" +__version__ = "1.22.2" __version_info__ = tuple(map(int, __version__.split(".")[:3])) __license__ = "MIT" __author__ = "OpenCyphal" diff --git a/pydsdl/_dsdl_definition.py b/pydsdl/_dsdl_definition.py index adf5383..097cf7c 100644 --- a/pydsdl/_dsdl_definition.py +++ b/pydsdl/_dsdl_definition.py @@ -31,8 +31,8 @@ class PathInferenceError(UndefinedDataTypeError): Raised when the namespace, type, fixed port ID, or version cannot be inferred from a file path. """ - def __init__(self, text: str, dsdl_path: Path, valid_dsdl_roots: list[Path]): - super().__init__(text=text, path=Path(dsdl_path)) + def __init__(self, text: str = "", dsdl_path: Path | None = None, valid_dsdl_roots: list[Path] | None = None): + super().__init__(text=text, path=dsdl_path) self.valid_dsdl_roots = valid_dsdl_roots[:] if valid_dsdl_roots is not None else None @@ -83,7 +83,7 @@ def _infer_path_to_root_from_first_found(cls, dsdl_path: Path, valid_dsdl_roots: "this root folder or provide a valid root path.", dsdl_path, valid_dsdl_roots, - ) + ) from None return directly_inferred # INFERENCE 2: The next easiest inference is when the target path is relative to a known dsdl root. These