Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getpass.getpass() fatally broken on Windows #4881

Closed
JamesTheAwesomeDude opened this issue Jan 26, 2024 · 3 comments
Closed

getpass.getpass() fatally broken on Windows #4881

JamesTheAwesomeDude opened this issue Jan 26, 2024 · 3 comments
Labels

Comments

@JamesTheAwesomeDude
Copy link

# Python 3.10.13 (fc59e61cfbff, Jan 14 2024, 16:27:58)
# [PyPy 7.3.15 with MSC v.1929 64 bit (AMD64)] on win32
# Type "help", "copyright", "credits" or "license" for more information.
import getpass

getpass.getpass('u> ')
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
#   File "C:\Users\AdministratorJames\OneDrive - Arcfield\Programs\PyPy310\Lib\getpass.py", line 103, in win_getpass
#     msvcrt.putwch(c)
#   File "C:\Users\AdministratorJames\OneDrive - Arcfield\Programs\PyPy310\Lib\msvcrt.py", line 112, in putwch
#     _lib._putwch(ord(ch))
# TypeError: initializer for ctype 'wchar_t' must be a unicode string of length 1, not int

getpass.getpass(b'b> ')
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
#   File "C:\Users\AdministratorJames\OneDrive - Arcfield\Programs\PyPy310\Lib\getpass.py", line 103, in win_getpass
#     msvcrt.putwch(c)
#   File "C:\Users\AdministratorJames\OneDrive - Arcfield\Programs\PyPy310\Lib\msvcrt.py", line 112, in putwch
#     _lib._putwch(ord(ch))
# TypeError: ord() expected string of length 1, but int found

Maybe related to #2999

@JamesTheAwesomeDude
Copy link
Author

JamesTheAwesomeDude commented Jan 26, 2024

It's worth noting that this renders twine upload difficult to use, but if you stick the token in the Credential Manager then you dodge this bug

https://github.com/pypa/twine/blob/4.0.2/twine/auth.py#L87

@mattip
Copy link
Member

mattip commented Jan 27, 2024

Fixed in 137e067. You can make the change to the pure-python msvcrt.py locally.

@mattip
Copy link
Member

mattip commented Jan 27, 2024

Thanks for the report. Closing, please reopen or open a new issue as needed.

@mattip mattip closed this as completed Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants