From 20c951bf16204c296c7196690250428520038730 Mon Sep 17 00:00:00 2001 From: Salih Yilboga Date: Tue, 27 Oct 2026 21:23:04 +0300 Subject: [PATCH 1/2] fix(main): support character devices in _is_file_or_fifo --- src/dotenv/main.py | 4 ++-- tests/test_fifo_dotenv.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) 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..86ddbd47 100644 --- a/tests/test_fifo_dotenv.py +++ b/tests/test_fifo_dotenv.py @@ -29,3 +29,13 @@ def writer(): assert ok is True assert os.getenv("MY_PASSWORD") == "pipe-secret" + + + +def test_load_dotenv_from_devnull(caplog): + import logging + 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 From 54588c449e800051626e7ce8eb455f10a2817116 Mon Sep 17 00:00:00 2001 From: Salih Yilboga Date: Tue, 27 Oct 2026 22:55:02 +0300 Subject: [PATCH 2/2] style(tests): fix ruff format in test_fifo_dotenv --- tests/test_fifo_dotenv.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_fifo_dotenv.py b/tests/test_fifo_dotenv.py index 86ddbd47..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 @@ -31,9 +32,7 @@ def writer(): assert os.getenv("MY_PASSWORD") == "pipe-secret" - def test_load_dotenv_from_devnull(caplog): - import logging with caplog.at_level(logging.INFO): ok = load_dotenv(dotenv_path=os.devnull, verbose=True)