msg10452 - (view) |
Author: Allan Crooks (amc1) |
Date: 2002-04-20 18:34 |
I'm currently running Python 2.2.1 on a Windows 98 box, and this is the code I have just run. ------- Python 2.2.1 (#34, Apr 9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import getpass >>> def x(): ... secret = getpass.getpass('Tell me a secret: ') ... stuff = raw_input ('Tell me something else: ') ... print 'The user told me the secret was "%s" and the other thing was "%s"' % (secret, stuff) ... >>> x() Tell me a secret: Tell me something else: The user told me the secret was "Autechre" and the other thing was "" >>> ------- This may seem normal, but I didn't get the opportunity to enter anything when the raw_input was called. I'm assuming that getpass leaves the newline character in the input buffer, which is then used by raw_input, leaving you unable to enter anything. |
|
|
msg10453 - (view) |
Author: Tim Peters (tim.peters) *  |
Date: 2002-04-20 20:10 |
Logged In: YES user_id=31435 Assigning to MarkH in case he has a bright idea. I don't. The problem is that getpass on Windows is implemented via raw Windows console I/O, and console I/O buffers interact in strange and undocumented ways with C's stdio buffers. I've never found a reliable way to keep them in synch, and MS says you can't mix the two, period. The only workaround I know of is to build your own raw_input() workalike out of the msvcrt module's console I/O routines (getch(), etc). |
|
|
msg10454 - (view) |
Author: Allan Crooks (amc1) |
Date: 2002-06-11 10:01 |
Logged In: YES user_id=39733 I've currently written a module which attempts to fix this problem, which you can get from here: http://ccec.sf.net/getpassfix.html However, as I've mentioned in the documentation, it is a hack, but the "platform" based solution should become a more suitable candidate as it is tested. |
|
|
msg10455 - (view) |
Author: Allan Crooks (amc1) |
Date: 2002-09-09 14:05 |
Logged In: YES user_id=39733 The function getpass_hack in the getpassfix module (referenced earlier) is a suitable alternative to the win_getpass function in the getpass module, but it should only be used if the operating system is Windows 95/98/ME (this is based on my observations so far). If we have a nice Pythonic way of determining what operating system that Python is running on (say, by using Marc-Andre Lemburg's platform module: http://www.lemburg.com/files/python/platform.py), we could then provide a straightforward fix. |
|
|
msg58701 - (view) |
Author: Joseph Armbruster (JosephArmbruster) |
Date: 2007-12-17 18:53 |
For the record, I tested this out with: url: http://svn.python.org/projects/python/branches/py3k: rev: 59540 OS Name: Microsoft Windows XP Professional OS Version: 5.1.2600 Service Pack 2 Build 2600 The following snippet appeared to behave as intended (i input "secret" them "something else"): >>> import getpass >>> def x(): ... secret = getpass.getpass('Tell me a secret: ') ... stuff = input('Tell me something else: ') ... print('The user told me the secret was "%s" and the other thing was "%s"' % (secret, stuff)) ... >>> x() Tell me a secret: Tell me something else: something else The user told me the secret was "secret" and the other thing was "something else " >>> |
|
|
msg61289 - (view) |
Author: Georg Brandl (georg.brandl) *  |
Date: 2008-01-20 13:54 |
So it seems to be fixed in NT -- we don't support 9x anymore in 2.6 up. |
|
|