kivy / kivy

Open source UI framework written in Python, running on Windows, Linux, macOS, Android and iOS
https://kivy.org
MIT License
17k stars 3.04k forks source link

Unexpected behavior by TypeError in `query_xinput` method #8674

Open marinelay opened 1 month ago

marinelay commented 1 month ago

Software Versions

Describe the bug I found a potential unexpected behavior due to a TypeError between str and bytes in query_xinput function.

https://github.com/kivy/kivy/blob/c0d4894384abb81cf4729984a1eaa4c437d266da/kivy/input/providers/probesysfs.py#L116-L136

The variable prop is bytes type, but this code is trying to split it using string type, such as prop.split('"')[1] at line 132. This always raise TypeError, so evpath is always None type when prop.startswith(b'Device Node') is true. I believe it is a miss point when supporting Python 3.x (related issue #3373 and pr #3417).

Expected behavior prop.split(b'"')[1]

To Reproduce I regret to say that I can't reproduce this error because I found this bug through my type checker. Nevertheless, I report this issue because I think it is the miss point when changing string to bytes. If this is not indeed a bug, I apologize for any inconvenience caused.

Thank you.

Code and Logs and screenshots

https://github.com/kivy/kivy/blob/c0d4894384abb81cf4729984a1eaa4c437d266da/kivy/input/providers/probesysfs.py#L116-L136