diff --git a/src/dotenv/main.py b/src/dotenv/main.py index 5faa7f0e..402bac76 100644 --- a/src/dotenv/main.py +++ b/src/dotenv/main.py @@ -519,7 +519,7 @@ def dotenv_values( def _is_file_or_fifo(path: StrPath) -> bool: """ - Return True if `path` exists and is either a regular file or a FIFO. + Return True if `path` exists and is either a regular file, a FIFO, or a character device. """ if os.path.isfile(path): return True @@ -529,4 +529,4 @@ def _is_file_or_fifo(path: StrPath) -> bool: except (FileNotFoundError, OSError): return False - return stat.S_ISFIFO(st.st_mode) + return stat.S_ISFIFO(st.st_mode) or stat.S_ISCHR(st.st_mode) diff --git a/tests/test_fifo_dotenv.py b/tests/test_fifo_dotenv.py index 2aa31779..fd2a65d7 100644 --- a/tests/test_fifo_dotenv.py +++ b/tests/test_fifo_dotenv.py @@ -1,3 +1,4 @@ +import logging import os import pathlib import sys @@ -29,3 +30,11 @@ def writer(): assert ok is True assert os.getenv("MY_PASSWORD") == "pipe-secret" + + +def test_load_dotenv_from_devnull(caplog): + with caplog.at_level(logging.INFO): + ok = load_dotenv(dotenv_path=os.devnull, verbose=True) + + assert ok is False + assert "could not find configuration file" not in caplog.text