[Python-bugs-list] [ python-Bugs-546558 ] Windows getpass bug
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 09 Sep 2002 07:05:56 -0700
Bugs item #546558, was opened at 2002-04-20 18:34
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=546558&group_id=5470
Category: Windows
Group: Platform-specific
Status: Open
Resolution: None
Priority: 5
Submitted By: Allan Crooks (amc1)
Assigned to: Mark Hammond (mhammond)
Summary: Windows getpass bug
Initial Comment:
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.
----------------------------------------------------------------------
>Comment By: Allan Crooks (amc1)
Date: 2002-09-09 14:05
Message:
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.
----------------------------------------------------------------------
Comment By: Allan Crooks (amc1)
Date: 2002-06-11 10:01
Message:
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.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-04-20 20:10
Message:
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).
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=546558&group_id=5470