From: <zy...@us...> - 2010-10-22 01:13:54
|
Revision: 7162 http://jython.svn.sourceforge.net/jython/?rev=7162&view=rev Author: zyasoft Date: 2010-10-22 01:13:48 +0000 (Fri, 22 Oct 2010) Log Message: ----------- Uses JLine support, when available, to turn off echoing in getpass.getpass. Fixes #1628. Modified Paths: -------------- trunk/jython/Lib/getpass.py trunk/jython/NEWS Modified: trunk/jython/Lib/getpass.py =================================================================== --- trunk/jython/Lib/getpass.py 2010-10-19 03:02:51 UTC (rev 7161) +++ trunk/jython/Lib/getpass.py 2010-10-22 01:13:48 UTC (rev 7162) @@ -14,10 +14,37 @@ # Authors: Piers Lauder (original) # Guido van Rossum (Windows support and cleanup) +import os import sys __all__ = ["getpass","getuser"] +def jython_getpass(prompt='Password: ', stream=None): + """Prompt for a password, with echo turned off. + The prompt is written on stream, by default stdout. + + Restore terminal settings at end. + """ + if stream is None: + stream = sys.stdout + + try: + terminal = sys._jy_interpreter.reader.terminal + except: + return default_getpass(prompt) + + echoed = terminal.getEcho() + terminal.disableEcho() + try: + passwd = _raw_input(prompt, stream) + finally: + if echoed: + terminal.enableEcho() + + stream.write('\n') + return passwd + + def unix_getpass(prompt='Password: ', stream=None): """Prompt for a password, with echo turned off. The prompt is written on stream, by default stdout. @@ -99,8 +126,6 @@ """ - import os - for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'): user = os.environ.get(name) if user: @@ -123,7 +148,10 @@ try: from EasyDialogs import AskPassword except ImportError: - getpass = default_getpass + if os.name == 'java': + getpass = jython_getpass + else: + getpass = default_getpass else: getpass = AskPassword else: Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-10-19 03:02:51 UTC (rev 7161) +++ trunk/jython/NEWS 2010-10-22 01:13:48 UTC (rev 7162) @@ -1,5 +1,9 @@ Jython NEWS +Jython 2.5.2rc2 + Bugs Fixed + - [ 1628 ] getpass.getpass echoes input + Jython 2.5.2rc1 Bugs Fixed - [ 1133 ] Support ipython and other completers with readline emulation This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |