diff options
author | Guido van Rossum <guido@python.org> | 1998-06-12 14:21:13 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-06-12 14:21:13 (GMT) |
commit | ae9ee7329d350b57a2d7b835e4e77a00b67e21b6 (patch) | |
tree | 5b17b9b3db1590371f3bdc7d175c9ed0f0d7801b /Lib/urllib.py | |
parent | c8f859a487c375983ec48102b108001a65d38e4b (diff) | |
download | cpython-ae9ee7329d350b57a2d7b835e4e77a00b67e21b6.zip cpython-ae9ee7329d350b57a2d7b835e4e77a00b67e21b6.tar.gz cpython-ae9ee7329d350b57a2d7b835e4e77a00b67e21b6.tar.bz2 |
Use the getpass module instead of having platform-specific echo on/off
code here.
Diffstat (limited to 'Lib/urllib.py')
-rw-r--r-- | Lib/urllib.py | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py index cabfeee..b9317f2 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -476,30 +476,17 @@ class FancyURLopener(URLopener): def prompt_user_passwd(self, host, realm): # Override this in a GUI environment! + import getpass try: user = raw_input("Enter username for %s at %s: " % (realm, host)) - self.echo_off() - try: - passwd = raw_input( - "Enter password for %s in %s at %s: " % - (user, realm, host)) - finally: - self.echo_on() + passwd = getpass.getpass( + "Enter password for %s in %s at %s: " % + (user, realm, host)) return user, passwd except KeyboardInterrupt: - return None, None - - def echo_off(self): - # XXX Is this sufficient??? - if hasattr(os, "system"): - os.system("stty -echo") - - def echo_on(self): - # XXX Is this sufficient??? - if hasattr(os, "system"): print - os.system("stty echo") + return None, None # Utility functions |