Under Windows the msvcrt.getch() call returns bytes, not chars. In Python 3 both types are not compatible, so concatenating the result to a string fails with a TypeError.
This code in Platform.getkey() throws TypeError exception ALWAYS in Windows:
buffer = ''
for c in self.getchars(blocking):
buffer += c
...
I have ammended it to work by allowing the platform classes to return bytes instead of chars:
buffer = ''
for c in self.getchars(blocking):
try:
buffer += c
except TypeError:
buffer += ''.join([chr(b) for b in c])
...
This supports any platform that captures chars, multichars, bytes or multibytes. And also complies with the Python philosophy of trying instead of checking.
Tested in:
Windows 8.1
Python 3.6.1
Under Windows the msvcrt.getch() call returns bytes, not chars. In Python 3 both types are not compatible, so concatenating the result to a string fails with a TypeError.
This code in Platform.getkey() throws TypeError exception ALWAYS in Windows:
I have ammended it to work by allowing the platform classes to return bytes instead of chars:
This supports any platform that captures chars, multichars, bytes or multibytes. And also complies with the Python philosophy of trying instead of checking.
Tested in:
Windows 8.1
Python 3.6.1