Skip to content

Conversation

@bswck
Copy link
Contributor

@bswck bswck commented Oct 18, 2025

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

@bswck
Copy link
Contributor Author

bswck commented Oct 23, 2025

Please merge #140298 first.

@bswck bswck marked this pull request as ready for review October 23, 2025 14:57
@bswck bswck marked this pull request as draft October 23, 2025 15:00
# Isolated mode implies -E, -P and -s, purifies sys.path and ignores PYTHON*
# variables.
if isolated:
cmd_line.append('-I')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To reuse this routine and spawn_asyncio_repl below, we need to have a knob to not pass -I since that ignores PYTHONSTARTUP completely.

The asyncio REPL currently doesn't comply to that, which is a separate issue I'll report having learnt this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tracking the -I edge case in #140648.

Comment on lines -295 to -311
def test_asyncio_repl_reaches_python_startup_script(self):
with os_helper.temp_dir() as tmpdir:
script = os.path.join(tmpdir, "pythonstartup.py")
with open(script, "w") as f:
f.write("print('pythonstartup done!')" + os.linesep)
f.write("exit(0)" + os.linesep)

env = os.environ.copy()
env["PYTHON_HISTORY"] = os.path.join(tmpdir, ".asyncio_history")
env["PYTHONSTARTUP"] = script
subprocess.check_call(
[sys.executable, "-m", "asyncio"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env,
timeout=SHORT_TIMEOUT,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Covered by TestPythonStartup now, so not needed here.

@bswck
Copy link
Contributor Author

bswck commented Oct 30, 2025

I've gotten a little background on precedent changes to this region of the tests code.
Turns out I was wrong saying that "linecache doesn't matter" -- it does; we need to bring the parts with line contents back.

@bswck bswck marked this pull request as draft October 30, 2025 07:07
for expected in (
"Traceback (most recent call last):",
'File "<stdin>", line 1, in <module>',
f'File "{startup_env['PYTHONSTARTUP']}", line ',
Copy link
Contributor Author

@bswck bswck Oct 30, 2025

Choose a reason for hiding this comment

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

I need to understand why line number 2 fails specifically on Windows and 3 is expected.

Copy link
Contributor Author

@bswck bswck left a comment

Choose a reason for hiding this comment

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

I'm also thinking that ideally we would test stdout and stderr separately.

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.

1 participant