Catch OSError also with errno=None (#392)

In Windows might OSError(errno = None) be raised instead of the already
catched exceptions in some cases (depending on the Python version)

Fixes #391
This commit is contained in:
Martin Rieder 2024-06-20 13:19:58 +02:00 committed by KV
parent 858b2664db
commit 42d10dfab4

View File

@ -416,7 +416,7 @@ def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> (Dict, Path):
# Catch this error, but raise any others # Catch this error, but raise any others
from errno import EINVAL, ENAMETOOLONG from errno import EINVAL, ENAMETOOLONG
if type(e) is OSError and e.errno not in (EINVAL, ENAMETOOLONG): if type(e) is OSError and e.errno not in (EINVAL, ENAMETOOLONG, None):
raise e raise e
# file does not exist; assume inp is a YAML string # file does not exist; assume inp is a YAML string
yaml_str = inp yaml_str = inp