Skip to content

gh-140006: Preserve fish prompt status in venv activation#144558

Open
ThanhNguyxn wants to merge 1 commit intopython:mainfrom
ThanhNguyxn:gh-140006-activate-fish-status
Open

gh-140006: Preserve fish prompt status in venv activation#144558
ThanhNguyxn wants to merge 1 commit intopython:mainfrom
ThanhNguyxn:gh-140006-activate-fish-status

Conversation

@ThanhNguyxn
Copy link

Summary

  • Replace echo "exit $old_status" | . with return $old_status in activate.fish so the fish prompt preserves the previous command status without sourcing exit from stdin.
  • Add test_activate_fish_script_preserves_status in Lib/test/test_venv.py to assert the generated script contains the fixed prompt-status line.
  • Add a Library NEWS entry for gh-140006.

Verification

  • python -m py_compile Lib/test/test_venv.py
  • python -c "import importlib.util, pathlib, tempfile, os; spec=importlib.util.spec_from_file_location('repo_venv', r'D:\Code\cpython\Lib\venv\__init__.py'); mod=importlib.util.module_from_spec(spec); spec.loader.exec_module(mod); d=tempfile.mkdtemp(); mod.create(d, with_pip=False, scm_ignore_files=frozenset()); p=pathlib.Path(d)/('Scripts' if os.name=='nt' else 'bin')/'activate.fish'; s=p.read_text(encoding='utf-8'); assert 'return $old_status' in s; assert 'echo \"exit $old_status\" | .' not in s; print('ok')"

@python-cla-bot
Copy link

python-cla-bot bot commented Feb 7, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant