GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Explicitly require Y/N for Command._ask · Issue #244 · python/pymanager

Explicitly require Y/N for Command._ask #244

New issue
Copy link
New issue
Copy link
Open
Open
Explicitly require Y/N for Command._ask#244
Copy link
Labels
enhancementNew feature or requestNew feature or request

Description

@AlvinRamoutar
AlvinRamoutar
opened on Dec 31, 2025
Issue body actions

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

pymanager/src/manage/commands.py

Lines 610 to 624 in 682d0f8

def _ask(self, fmt, *args, yn_text="Y/n", expect_char="y"):
if not self.confirm:
return True
if not LOGGER.would_print():
LOGGER.warn("Cannot prompt for confirmation at this logging level. "
"Pass --yes to accept the default response.")
if not LOGGER.would_log_to_console(logging.WARN):
sys.exit(1)
return False
LOGGER.print(f"{fmt} [{yn_text}] ", *args, end="")
try:
resp = input().casefold()
except Exception:
return False
return not resp or resp.startswith(expect_char.casefold())

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.

Activity

  1. AlvinRamoutar
    added
    enhancementNew feature or requestNew feature or request
    on Dec 31, 2025
  2. AlvinRamoutar
    added a commit that references this issue on Dec 31, 2025

    pythonGH-244 explicitly require Y/N for Command._ask

    92566d8
  3. AlvinRamoutar commented on Dec 31, 2025

    @AlvinRamoutar
    AlvinRamoutar
    on Dec 31, 2025
    Author
    More actions

    I opened #245 for this - understandably its such a small issue that I'm alright if this gets closed.
    Nonetheless, thanks for the Windows support :)

  4. zooba commented on Jan 14, 2026

    @zooba
    zooba
    on Jan 14, 2026
    Member
    More actions

    I'm interested why you expect typing "yes" to cancel (I know that's not your example, but that's the effect of the proposed change).

    In general, I'm opposed to changes that enforce arbitrary limitations on the user experience - allowing any response and matching the first character was intentional.

    But if there's a solid reason to do it, I could be convinced. "I panicked and typed ynh" is close enough to "I panicked and typed y" that I don't think we meaningfully solve the panic issue with this change (panicking and pressing Ctrl+C should abort).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.