-
-
Notifications
You must be signed in to change notification settings - Fork 33k
Closed
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Running getpass.getpass(echo_char="***")
works until a character is entered, at which point a traceback error occurs.
import getpass
getpass.getpass(echo_char="***")
Password: Traceback (most recent call last):
File "<python-input-10>", line 1, in <module>
getpass.getpass(echo_char="***")
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "...\pythoncore-3.14-64\Lib\getpass.py", line 129, in win_getpass
msvcrt.putwch(echo_char)
~~~~~~~~~~~~~^^^^^^^^^^^
TypeError: putwch(): argument must be a unicode character, not a string of length 3
Validation should occur upon input for this argument, and getpass
should raise a ValueError
stating: "'echo_char' must be a single-character ASCII string, not a string of length 3" (with ASCII only being bolded in this write-up for emphasis that a Unicode character cannot be used).
Additionally, the error message language should be revised when a non-ASCII string is entered:
import getpass
getpass.getpass(echo_char="Æ")
Traceback (most recent call last):
File "<python-input-11>", line 1, in <module>
getpass.getpass(echo_char="Æ")
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "...\pythoncore-3.14-64\Lib\getpass.py", line 109, in win_getpass
_check_echo_char(echo_char)
~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "...\pythoncore-3.14-64\Lib\getpass.py", line 149, in _check_echo_char
raise ValueError("'echo_char' must be a printable ASCII string, "
f"got: {echo_char!r}")
ValueError: 'echo_char' must be a printable ASCII string, got: 'Æ'
Better language would be: "'echo_char' must be a single-character ASCII string, got: 'Æ'".
With agreement, I can submit a pull request.
CPython versions tested on:
3.14
Operating systems tested on:
Windows
Linked PRs
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error