]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Use the getpass module instead of having platform-specific echo on/off
authorGuido van Rossum <guido@python.org>
Fri, 12 Jun 1998 14:21:13 +0000 (14:21 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 12 Jun 1998 14:21:13 +0000 (14:21 +0000)
code here.

Lib/urllib.py

index cabfeeeb6d7a4cb78474ceda3a0aff25fb5ecdf0..b9317f28b32a61b009efc7727deff35305178634 100644 (file)
@@ -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