Skip to content

Decide how to use echo_char in getpass.fallback_getpass #140535

@qc-m

Description

@qc-m

Hello everyone, I am a Chinese high school student. This is my first contribution to cpython on GitHub. If there are any errors, please kindly point them out. Thank you!
I noticed that in the getpass library of Python 3.14, there was a seemingly useless function call in fallback_getpass: _check_echo. This function was originally designed to check if the echo character is valid, but I think this call is redundant because:

  1. fallback_getpass is only called when the terminal settings cannot be controlled, and the echo_char parameter actually does not work properly at this time
    2.In a fallback scenario, even if echo_char is provided, password echo control cannot be implemented
    I suggest removing this unnecessary call. Modify the code as follows:
def fallback_getpass(prompt='Password: ', stream=None, *, echo_char=None):
    # remove the function call
    import warnings
    warnings.warn("Can not control echo on the terminal.", GetPassWarning,
                  stacklevel=2)
    if not stream:
        stream = sys.stderr
    print("Warning: Password input may be echoed.", file=stream)
    return _raw_input(prompt, stream, echo_char=echo_char)

By the way,can we make IDLE support getpass?I think it is important for the beginners!

At last,if I say something wrong, please tell me why and forgive me, thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15new features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions