Skip to content

Fix find_dotenv in interactive IDE consoles - #695

Open
cucuwang wants to merge 1 commit into
theskumar:mainfrom
cucuwang:codex/fix-596-pseudo-filename-cwd
Open

Fix find_dotenv in interactive IDE consoles#695
cucuwang wants to merge 1 commit into
theskumar:mainfrom
cucuwang:codex/fix-596-pseudo-filename-cwd

Conversation

@cucuwang

@cucuwang cucuwang commented Sep 6, 2026

Copy link
Copy Markdown

Fixes #596.

Summary

find_dotenv now treats angle-bracket pseudo-filenames such as <input> as interactive code and searches from the current working directory. Missing zip-member paths continue to be skipped so the existing zip-import behavior is preserved.

Tests

  • uv run --with-requirements requirements.txt pytest -q (256 passed)
  • tox -e lint (Ruff and mypy for Python 3.10 through 3.14)

AI assistance

Codex was used to implement, test, and review this change.

Copilot AI lite review requested due to automatic review settings September 6, 2026 04:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The behavioral change is narrowly scoped, preserves the prior zip-import skip behavior, and is covered by a focused regression test.

Pull request overview

This pull request adjusts find_dotenv’s call-site discovery so that interactive console frames with angle-bracket pseudo-filenames (e.g. <input>) are treated as interactive code and the search starts from the current working directory, restoring expected behavior in IDE consoles (per #596) while preserving existing zip-import handling.

Changes:

  • Treat angle-bracket pseudo-filenames in stack frames as interactive code and fall back to os.getcwd() for the search start path.
  • Add a regression test that exercises find_dotenv() when executed from compiled code with co_filename="<input>".
  • Document the fix in the Unreleased changelog.
File summaries
File Description
src/dotenv/main.py Updates stack-frame filename handling to treat pseudo-filenames as interactive and use CWD as the search root.
tests/test_main.py Adds a subprocess-based regression test for interactive pseudo-filename execution.
CHANGELOG.md Notes the interactive console .env discovery fix under Unreleased.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread CHANGELOG.md Outdated
Comment thread src/dotenv/main.py Outdated
@cucuwang
cucuwang force-pushed the codex/fix-596-pseudo-filename-cwd branch from 18a3ede to 0a54fa1 Compare September 6, 2026 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

load_dotenv() default behavior change in PyCharm interactive console

2 participants