python getpass module is not taking German characters as input

298 views Asked by At

I am trying to enter password having German characters using python getpass module on Windows 7. Python version is 2.7.8

  • First I set the system locale as German(Germany) and reboot.
  • The command prompt codepage is now set to cp850 which supports German characters.
  • Then I execute getpass in command prompt as follows :

    pwd = getpass.getpass()

    Password:
    

    print pwd

  • I had input ö as password and printing it gives me nothing. This is confirmed by printing the length of the password which is 0.

The same is working with Chinese, Japanese and Korean characters when I set the corresponding locale.

I have the same thing with python 2.3.5 and same issue persists.

Please let me know if I am doing something wrong?

1

There are 1 answers

0
Shobhit Ranjan On BEST ANSWER

I was entering the German character (ö) by typing following : alt + 0246. But typing the same character directly from the German keyboard (semi-colon ';' on American keyboard) is working fine.

However, still I am confused as to what is the difference between above two. Maybe alt code characters are in a different encoding than what is given by sys.stdin.encoding!!!