python / python/pymanager

Explicitly require Y/N for Command._ask

Open
#244 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
344
Forks
74
Avg merge
1d 3h
Merged PRs (30d)
7

Description

Is your feature request related to a problem? Please describe.
Had pymanager uninstall <tag> in my terminal and in a dumb panic on my split keyboard, submitted the characters yhn:

pymanager uninstall 3.13.11
Uninstall Python 3.13.11? [Y/n] yhn

Expected to cancel/break since yhn does not match a provided option - y or n.
In actuality, it proceeded to remove that python installation.

Describe the solution you'd like
Literally match for the submitted character y or n.

Describe alternatives you've considered
Not panicking and hitting n (or hitting anything else really, as long as it does not start with y)

Additional context
Was a silly mistake that costed me enough rebuild time that I came back just to figure out why it happened.
https://github.com/python/pymanager/blob/main/src/manage/commands.py#L624

https://github.com/python/pymanager/blob/682d0f87a0eadb3e137b065cda0b3a74d8e83fa2/src/manage/commands.py#L610-L624

Since we match via startswith, it does not matter what the remaining characters are - as long as expect_char is the first char, then _ask evaluates.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/manage/commands.py around lines 610-624, especially the Command._ask entry point and the linked prompt logic. Verify that an input such as yhn is rejected rather than treated as y, while the intended Y/N responses retain their expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.