From 7b5afcfc8a17bf93a030313cac2f89c76a0bfc8d Mon Sep 17 00:00:00 2001 From: CHOI JI WOONG Date: Tue, 10 Mar 2026 15:21:22 +0900 Subject: [PATCH 1/2] Fix: update test_find_dotenv_no_file_raise to expect FileNotFoundError Updated test_main.py (line 351) to replace IOError with FileNotFoundError so that the test matches the updated exception handling in main.py. --- tests/test_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_main.py b/tests/test_main.py index 50703af0..7f2d23cd 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -346,7 +346,7 @@ def test_find_dotenv_no_file_raise(tmp_path): leaf = prepare_file_hierarchy(tmp_path) os.chdir(leaf) - with pytest.raises(IOError): + with pytest.raises(FileNotFoundError): dotenv.find_dotenv(raise_error_if_not_found=True, usecwd=True) From a0d925f409ed94fe57095e4615c1e336e2de65b5 Mon Sep 17 00:00:00 2001 From: CHOI JI WOONG Date: Tue, 10 Mar 2026 15:21:57 +0900 Subject: [PATCH 2/2] Fix: Use FileNotFoundError for file not found in main.py Replaced IOError with FileNotFoundError on line 377 of main.py to use a more specific and appropriate exception for file not found errors. --- src/dotenv/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dotenv/main.py b/src/dotenv/main.py index 491634d9..c33148cb 100644 --- a/src/dotenv/main.py +++ b/src/dotenv/main.py @@ -375,7 +375,7 @@ def _is_debugger(): return check_path if raise_error_if_not_found: - raise IOError("File not found") + raise FileNotFoundError("File not found") return ""