Message215697
getpass.getpass() fails with non-ASCII characters in prompt.
The attached example scripts (for Python 2 and 3) contain non-ASCII unicode prompt (Polish "hasło" == English "password") written in UTF-8.
Python-2 version fails always. Python-3 version fails in non-UTF-8 locale.
$ ./getpass_test_python2
Traceback (most recent call last):
File "./getpass_test_python2", line 5, in <module>
getpass.getpass(u"Hasło: ")
File "/usr/lib64/python2.7/getpass.py", line 71, in unix_getpass
passwd = _raw_input(prompt, stream, input=input)
File "/usr/lib64/python2.7/getpass.py", line 128, in _raw_input
prompt = str(prompt)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0142' in position 3: ordinal not in range(128)
$ LC_ALL="en_US.UTF-8" ./getpass_test_python3
Hasło:
$ LC_ALL="C" ./getpass_test_python3
Traceback (most recent call last):
File "./getpass_test_python3", line 5, in <module>
getpass.getpass("Has\u0142o: ")
File "/usr/lib64/python3.4/getpass.py", line 78, in unix_getpass
passwd = _raw_input(prompt, stream, input=input)
File "/usr/lib64/python3.4/getpass.py", line 138, in _raw_input
stream.write(prompt)
UnicodeEncodeError: 'ascii' codec can't encode character '\u0142' in position 3: ordinal not in range(128)
$ |
|
Date |
User |
Action |
Args |
2014-04-07 11:23:55 | Arfrever | set | recipients:
+ Arfrever |
2014-04-07 11:23:55 | Arfrever | set | messageid: <1396869835.69.0.462900859226.issue21169@psf.upfronthosting.co.za> |
2014-04-07 11:23:55 | Arfrever | link | issue21169 messages |
2014-04-07 11:23:55 | Arfrever | create | |
|