Turn off echo getpass.getpass () in IDLE

I would like to enter a password into the IDLE terminal on Windows without echoing.

Usually password entry is possible with python using the getpass.getpass () function, but the following warning message appears in IDLE:

GetPassWarning: Can not control echo on the terminal. 
Warning: Password input may be echoed.

      

I found out this is because IDLE replaces sys.stdin with a different object:

if sys.stdin is not sys.__stdin__:
    return fallback_getpass(prompt, stream)

      

However, I have not been able to find a solution. Does anyone have an answer or some other way to enter the password into the IDLE terminal without echoing?

+3


source to share


1 answer


As an IDLE developer with some familiarity with internal IDLEs, I do not believe that it is possible to suppress the display of characters, but not change the behavior in response to input('prompt')

without significantly changing the IDLE code.

But even that would not be enough for getpass.getpass

, since it calls one of unix_getpass

, win_getpass

or default_getpass

, and the first two use system-specific low-level functions that bypass stdin.



From a design point of view: IDLE, as the name says, is a program development environment. Usually, programs you develop, and sometimes need to be executed directly by Python, without going through IDLE. Usually Python connects to a terminal window. The IDLE Shell is based on the tkinter text widget, which is a multi-line editor, not a terminal. This is why you can enter, withdraw, and edit complete multi-line statements, rather than just one line at a time.

+3


source







All Articles