all Python 3getpassexception
getpass.GetPassWarning
password input
A warning (a UserWarning subclass) that getpass() issues when it cannot hide the password input.
Syntax
warnings.simplefilter('error', getpass.GetPassWarning)
It shows up in IDEs, when running without a terminal and in similar settings: the password is then read from stdin and may be visible on screen. It is a warning, not an exception — the program keeps going. To refuse a visible password, turn it into an error: warnings.simplefilter('error', getpass.GetPassWarning).
Examples
import getpass, warnings
print(issubclass(getpass.GetPassWarning, UserWarning)) # → True
warnings.simplefilter('error', getpass.GetPassWarning)
try:
warnings.warn('Password input may be echoed.', getpass.GetPassWarning)
except getpass.GetPassWarning as e:
print('ошибка:', e) # → ошибка: Password input may be echoed.
See also
Open in the full glossarydocs.python.orgReport an inaccuracy