Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle OSError [errno.EINVAL] that might be raised in Windows #346

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/wireviz/wireviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,12 @@ def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> (Dict, Path):
yaml_str = open_file_read(yaml_path).read()
except (FileNotFoundError, OSError) as e:
# if inp is a long YAML string, Pathlib will raise OSError: [errno.ENAMETOOLONG]
# (in Windows, it seems OSError [errno.EINVAL] might be raised in some cases)
# when trying to expand and resolve it as a path.
# Catch this error, but raise any others
from errno import ENAMETOOLONG
from errno import EINVAL, ENAMETOOLONG

if type(e) is OSError and e.errno != ENAMETOOLONG:
if type(e) is OSError and e.errno not in (EINVAL, ENAMETOOLONG):
raise e
# file does not exist; assume inp is a YAML string
yaml_str = inp
Expand Down
Loading