Skip to content

gh-140287: Handle PYTHONSTARTUP script exceptions in the asyncio REPL#140288

Open
johnslavik wants to merge 54 commits intopython:mainfrom
johnslavik:asyncio-repl-handle-python-startup
Open

gh-140287: Handle PYTHONSTARTUP script exceptions in the asyncio REPL#140288
johnslavik wants to merge 54 commits intopython:mainfrom
johnslavik:asyncio-repl-handle-python-startup

Conversation

@johnslavik
Copy link
Copy Markdown
Member

@johnslavik johnslavik commented Oct 18, 2025

This is generally a work in progress; tests are needed.
The asyncio patch is simple and ready.

@johnslavik
Copy link
Copy Markdown
Member Author

Please merge #140298 first.

@johnslavik johnslavik marked this pull request as ready for review October 23, 2025 14:57
@johnslavik johnslavik marked this pull request as draft October 23, 2025 15:00
Copy link
Copy Markdown
Member Author

@johnslavik johnslavik left a comment

Choose a reason for hiding this comment

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

I'll come back to this after completing GH-140648.

@johnslavik
Copy link
Copy Markdown
Member Author

I've realized that this isn't testing what it is supposed to test. I'll come back to this later.

Comment on lines +71 to +81
@contextmanager
def new_pythonstartup_env(*, code: str, histfile: str = ".pythonhist"):
"""Create environment variables for a PYTHONSTARTUP script in a temporary directory."""
with os_helper.temp_dir() as tmpdir:
filename = os.path.join(tmpdir, "pythonstartup.py")
with open(filename, "w") as f:
f.write(code)
yield {
"PYTHONSTARTUP": filename,
"PYTHON_HISTORY": os.path.join(tmpdir, histfile)
}
Copy link
Copy Markdown
Member Author

@johnslavik johnslavik Apr 1, 2026

Choose a reason for hiding this comment

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

This will be useful in #143023. I can inline it in test_pythonstartup_failure until then if we want to increase locality and not overdo idioms prematurely.

@johnslavik johnslavik marked this pull request as ready for review April 1, 2026 21:41
@johnslavik
Copy link
Copy Markdown
Member Author

cc @kumaraditya303

@johnslavik johnslavik added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Apr 5, 2026
@johnslavik johnslavik requested a review from ambv April 5, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants