prompt-toolkit / prompt-toolkit/python-prompt-toolkit

Single is_password prompt changes all further prompts

Open
#967 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

Hey there,

when using a prompt session the default value for is_password will be overwritten by a single call to prompt("Hello World", is_password=True). Any further prompts without having the attribute is_password set will still be in password mode.

Here's an example:

from prompt_toolkit import PromptSession
session = PromptSession()
session.prompt("Your Password:", is_password=True)
session.prompt("Your Magic Number:")

The output is the following:

Your Password:**** 
Your Magic Number:** 

Currently I have to explicitly set is_password=False on every further prompt after using a single prompt with is_password=True. Is this the expected behaviour? I would expect the second prompt to show the entered characters.
Our shouldn't you use a prompt session for entering a password? This however will makes things complicated when using a global style in your prompt session for example.

I'm using prompt_toolkit 3.0.0 from source at commit 850a4cdd21713060d5cbd1dfd923b69b1c696f4b

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 by reproducing the two-call PromptSession example shown in the issue, focusing on how prompt() handles the is_password argument between calls. Trace the PromptSession prompt entry point and add a regression test showing that a one-off password prompt does not affect the next prompt. Done means the second prompt displays entered characters without explicitly setting is_password=False.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.