getpass.getpass() on Win2K/XP
djw
codeguru at hp.com
Fri Dec 6 18:42:54 EST 2002
Question (possible bug?) using getpass.getpass() on Win2K/XP:
From getpass.py:
# Bind the name getpass to the appropriate function
try:
import termios
except ImportError:
try:
import msvcrt
except ImportError:
try:
from EasyDialogs import AskPassword
except ImportError:
getpass = default_getpass
else:
getpass = AskPassword
else:
getpass = win_getpass
else:
getpass = unix_getpass
On my 2.2.1 install of ActiveState, 'import termios' does not fail. So,
getpass() gets bound to unix_getpass() and then fails with:
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python22\lib\getpass.py", line 29, in unix_getpass
old = termios.tcgetattr(fd) # a copy to save
AttributeError: 'module' object has no attribute 'tcgetattr'
It seems from the docstring in termios that this module is deprecated,
so is it just the case that getpass hasn't been updated to reflect that yet?
The workaround, of course, is to call win_getpass() directly, but that
kind of kills the platform neutrality of this module.
/d/
More information about the Python-list
mailing list