Fix find_dotenv in interactive IDE consoles - #695
Open
cucuwang wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
🟢 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 withco_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.
cucuwang
force-pushed
the
codex/fix-596-pseudo-filename-cwd
branch
from
September 6, 2026 04:50
18a3ede to
0a54fa1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #596.
Summary
find_dotenvnow 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.