From 6e0f2ae462d015e39630f608764da461a5da28e7 Mon Sep 17 00:00:00 2001 From: btee Date: Tue, 30 Jan 2024 11:07:49 +0100 Subject: [PATCH] Change assertion into the loop invariant --- src/dotenv/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dotenv/main.py b/src/dotenv/main.py index 7bc54285..ece9e00a 100644 --- a/src/dotenv/main.py +++ b/src/dotenv/main.py @@ -299,10 +299,10 @@ def _is_interactive(): frame = sys._getframe() current_file = __file__ - while frame.f_code.co_filename == current_file or not os.path.exists( - frame.f_code.co_filename + while frame.f_back is not None and ( + frame.f_code.co_filename == current_file + or not os.path.exists(frame.f_code.co_filename) ): - assert frame.f_back is not None frame = frame.f_back frame_filename = frame.f_code.co_filename path = os.path.dirname(os.path.abspath(frame_filename))