Skip to content

🐛 fix(activation): restore the user's pydoc alias on xonsh deactivate - #3591

Merged
gaborbernat merged 2 commits into
pypa:mainfrom
Pratik-Kumar-Dhakar:fix/xonsh-restore-pydoc
Nov 20, 2026
Merged

gaborbernat merged 2 commits into
pypa:mainfrom
Pratik-Kumar-Dhakar:fix/xonsh-restore-pydoc

Conversation

@Pratik-Kumar-Dhakar

@Pratik-Kumar-Dhakar Pratik-Kumar-Dhakar commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3586

Xonsh activation replaced a user's pydoc alias and removed it on deactivation. The activator now restores that alias, including after switching environments. An alias that refers to another alias keeps that reference, so later changes to its target still apply. This matches #3529 for PowerShell.

The activator saves the raw alias definition before installing its own. It restores the saved definition only if it registered the replacement; this lets the next activator deactivate the previous one without removing the user's alias.

Security scope (activation script): the outside input is the user's own pydoc alias definition. The script stores and reassigns that definition without executing it as source.

Thanks for contributing, make sure you address all the checklists (for details on how see development documentation)

  • ran the linter to address style issues (tox -e fix)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added a docs/changelog/+short-description.<type>.rst fragment for each user-facing change, or applied skip news
  • updated/extended the documentation
  • for changes to activation scripts, pyvenv.cfg, wheel downloads, app-data or release workflows: explained in the PR text which outside input the change handles
  • ran tests on Python 3.9 and 3.15 (the affected test modules, with pytest in 3.9 and 3.15 environments rather than through tox. On 3.9, one fixture-teardown error also happens on main in my environment)
  • linked upstream issues beside any temporary interpreter overrides
  • kept the PR in draft until CI passes

@Pratik-Kumar-Dhakar
Pratik-Kumar-Dhakar marked this pull request as ready for review November 19, 2026 16:59
Pratik-Kumar-Dhakar and others added 2 commits November 19, 2026 17:12
Activation replaced and then removed a user-defined pydoc alias. Save it
on activation and restore it on deactivation, including when switching
environments.
Xonsh resolves alias references in aliases.get(), which freezes the
command when activation saves pydoc. Read the raw mapping entry so
deactivation restores the user's alias chain.
@gaborbernat
gaborbernat force-pushed the fix/xonsh-restore-pydoc branch from b1c96d3 to 1099cc7 Compare November 20, 2026 01:13
@gaborbernat
gaborbernat merged commit eb8f736 into pypa:main Nov 20, 2026
82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xonsh activator removes the user's own pydoc alias on deactivate

2 participants