Skip to content

Commit ff6afac

Browse files
martinriederkvid
authored andcommitted
Update comment in src/wireviz/wireviz.py (#392)
Clarify all exceptions catched, including changes in #392 Co-authored-by: kvid <kvid@users.noreply.github.com>
1 parent d4902ce commit ff6afac

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/wireviz/wireviz.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,13 @@ def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> Tuple[Dict, Path]:
420420
# if no FileNotFoundError exception happens, get file contents
421421
yaml_str = open_file_read(yaml_path).read()
422422
except (FileNotFoundError, OSError, ValueError) as e:
423-
# if inp is a long YAML string, Pathlib will raise OSError: [errno.ENAMETOOLONG]
424-
# (in Windows, it seems OSError [errno.EINVAL] might be raised in some cases)
425-
# when trying to expand and resolve it as a path.
426-
# Catch this error, but raise any others
423+
# if inp is a long YAML string, Pathlib will normally raise
424+
# FileNotFoundError or OSError(errno = ENAMETOOLONG) when
425+
# trying to expand and resolve it as a path, but in Windows
426+
# might ValueError or OSError(errno = EINVAL or None) be raised
427+
# instead in some cases (depending on the Python version).
428+
# Catch these specific errors, but raise any others.
429+
427430
if type(e) is OSError and e.errno not in (EINVAL, ENAMETOOLONG, None):
428431
raise e
429432
# file does not exist; assume inp is a YAML string

0 commit comments

Comments
 (0)