why does getpass() show the input?

Discussion in 'Python' started by John Salerno, Aug 9, 2006.

  1. John Salerno

    John Salerno Guest

    I'm guessing this might have something to do with my particular system?

    >>> getpass.getpass()

    Warning: Problem with getpass. Passwords may be echoed.
    Password: hello
    'hello'
    John Salerno, Aug 9, 2006
    #1
    1. Advertising

  2. John Salerno

    John Machin Guest

    John Salerno wrote:
    > I'm guessing this might have something to do with my particular system?


    Is that meant to be a statement or a question?

    If it's a question, and you'd like a helpful answer, try telling us at
    least (1) what platform you are running on, (2) did you enter that at
    the usual OS command line (with/without readline), or in an IDE (e.g
    IDLE) or some other shell (e.g. IPython) (3) version numbers of Python
    and any other relevant software (4) Is the question idle curiosity or
    do you need a fix real soon now (5) have you been molesting your
    console with e.g. stty ...

    >
    > >>> getpass.getpass()

    > Warning: Problem with getpass. Passwords may be echoed.
    > Password: hello
    > 'hello'
    John Machin, Aug 10, 2006
    #2
    1. Advertising

  3. John Salerno

    John Machin Guest

    John Machin wrote:

    >
    > If it's a question, and you'd like a helpful answer, try telling us at
    > least

    [snip]

    plus (6) what conclusions you have after reading
    <your_Python_installation_directory>/Lib/getpass.py
    John Machin, Aug 10, 2006
    #3
  4. rob@aranea:~$ python
    Python 2.4.2 (#2, Sep 30 2005, 21:19:01)
    [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    >>> # The cause of this problem is because you're using the console

    .... # to test getpass. getpass.getpass()'s return value is the
    .... # password inputted, but because you're not capturing its return
    .... # value, the console is printing it. Let me demonstrate:
    ....
    >>> import getpass
    >>> getpass.getpass()

    Password:
    'This is a password'
    >>> # The password is printed, however, if I capture the output:

    ....
    >>> mypass = getpass.getpass()

    Password:
    >>> # The password is not shown, and is stored in mypass:

    ....
    >>> print mypass

    This is a password
    >>>
    >>> # Thank you, and goodnight.

    .... #
    .... # -Rob
    ....
    >>>


    On Wed, 09 Aug 2006 20:42:18 +0000, John Salerno wrote:

    > I'm guessing this might have something to do with my particular system?
    >
    > >>> getpass.getpass()

    > Warning: Problem with getpass. Passwords may be echoed.
    > Password: hello
    > 'hello'
    Robin Haswell, Aug 10, 2006
    #4
  5. John Salerno

    John Machin Guest

    Robin Haswell wrote:
    > rob@aranea:~$ python
    > Python 2.4.2 (#2, Sep 30 2005, 21:19:01)
    > [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
    > Type "help", "copyright", "credits" or "license" for more information.
    > >>>
    > >>> # The cause of this problem is because you're using the console

    > ... # to test getpass. getpass.getpass()'s return value is the
    > ... # password inputted, but because you're not capturing its return
    > ... # value, the console is printing it.


    Please look again at the OP's post. Here is the relevant part, with my
    annotations:

    #>>> getpass.getpass()
    Warning: Problem with getpass. Passwords may be echoed. <<<=== Ooooh!
    What's printing that?
    Password: hello <<<<<<<<<====== echoing his input as he typed
    'hello' <<<<<<=== what you call "the console is printing it"
    John Machin, Aug 10, 2006
    #5
  6. > Please look again at the OP's post. Here is the relevant part, with my
    > annotations:




    You're right, my bad. It's still first thing in the morning here :'(

    -Rob
    Robin Haswell, Aug 10, 2006
    #6
  7. John Salerno

    John Salerno Guest

    John Machin wrote:

    > Is that meant to be a statement or a question?


    Heh heh, sorry! I guess both. Let me clarify:

    > (1) what platform you are running on,


    WinXP

    >(2) did you enter that at
    > the usual OS command line (with/without readline), or in an IDE (e.g
    > IDLE) or some other shell (e.g. IPython)


    IDLE

    >(3) version numbers of Python
    > and any other relevant software


    2.4.3 and nothing else special is running

    >(4) Is the question idle curiosity


    yes, most of my questions are :)

    >(5) have you been molesting your
    > console with e.g. stty ...


    nope, none of that stuff

    > (6) what conclusions you have after reading
    > <your_Python_installation_directory>/Lib/getpass.py


    if sys.stdin is not sys.__stdin__:
    return default_getpass(prompt)

    Ah ha! So it only works at the command prompt, unless I change
    __stdin__? Thanks for teaching me a lesson!
    John Salerno, Aug 10, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lucas Raab

    getpass

    Lucas Raab, Oct 12, 2003, in forum: Python
    Replies:
    1
    Views:
    483
    Jorge Godoy
    Oct 12, 2003
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,805
    Smokey Grindel
    Dec 2, 2006
  3. How to fool getpass()

    , Aug 15, 2006, in forum: C Programming
    Replies:
    2
    Views:
    360
    jmcgill
    Aug 15, 2006
  4. Andrew

    getpass and IDEs

    Andrew, Feb 25, 2011, in forum: Python
    Replies:
    3
    Views:
    513
    Nobody
    Feb 26, 2011
  5. Yang Zhang

    getpass

    Yang Zhang, Apr 11, 2008, in forum: Ruby
    Replies:
    7
    Views:
    144
    Todd Benson
    Apr 13, 2008
Loading...

Share This Page