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))