You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when win_unicode_console is enabled, and use getpass.getpass() I get:
C:\Python27\lib\getpass.py:92: GetPassWarning: Can not control echo on the terminal.
return fallback_getpass(prompt, stream)
Warning: Password input may be echoed.
Password: password
For now I resorted to disabling it immediately before I call getpass and reenabling it afterwards:
Also, what is the preferred way to check from code if win_unicode_console has been previously enabled? It would be nice if there was a function returning a bool which tells whether win_unicode_console is already enabled or not. My global HAS_WIN_UNICODE_CONSOLE in the code above is True whenever win_unicode_console can be imported, but that doesn't mean it is also enabled. I don't want to re-enable it if it wasn't before running getpass.
Thanks!
Cosimo
The text was updated successfully, but these errors were encountered:
fromcontextlibimport_RedirectStreamimportgetpassclassredirect_stdin(_RedirectStream):
"""Context manager for temporarily redirecting stdin to another file."""_stream="stdin"defprompt_password():
withredirect_stdin(sys.__stdin__):
returngetpass.getpass()
Note it is not needed to mention win_unicode_console and that is a good thing. Application of win_unicode_console should be transparent and ordinary code shouldn't explicitly mention it. Also, it is not possible to signal whether win_unicode_console is enabled or not since enabling it may apply various fixes depending on Python version, platform version, and an explicit demand. There is no single “enabled” state.
when
win_unicode_console
is enabled, and usegetpass.getpass()
I get:For now I resorted to disabling it immediately before I call
getpass
and reenabling it afterwards:Do you know any better workaround or fix?
Also, what is the preferred way to check from code if
win_unicode_console
has been previously enabled? It would be nice if there was a function returning a bool which tells whether win_unicode_console is already enabled or not. My globalHAS_WIN_UNICODE_CONSOLE
in the code above is True wheneverwin_unicode_console
can be imported, but that doesn't mean it is also enabled. I don't want to re-enable it if it wasn't before running getpass.Thanks!
Cosimo
The text was updated successfully, but these errors were encountered: