moses-palmer / pynput

Sends virtual input commands
GNU Lesser General Public License v3.0
1.79k stars 248 forks source link

Python crash with Pynput and PySide #426

Closed zoltanszocs closed 2 years ago

zoltanszocs commented 2 years ago

Description After I added a global shortcut listener using Pynput, python crashes whenever I ctrl + click any UI element. I attached the macOS crash report.

Platform and pynput version HW Mac mini Intel Core i5 macOs Big Sur 11.6
pynput 1.7.5 PySide6 6.2.1

To Reproduce Start the script below and ctrl-(left) click on the window. Some times it takes some other interaction with the window to make it crash: simple clicks, window resize then it crashes at the ctrl-click.

from PySide6 import QtWidgets
from pynput import keyboard

def on_activate():
    print(f'Keypress detected.')

app = QtWidgets.QApplication()
w = QtWidgets.QWidget()
w.show()

shortcut_listener = keyboard.GlobalHotKeys({'<shift>+<space>': on_activate})
shortcut_listener.start()
app.exec()

crash_report.txt

moses-palmer commented 2 years ago

This is possibly related to #366.

pynput does not contain any native code that could cause a SIGILL, but the crash report certainly indicates a bug in one of libraries used. I will close this issue, as I do not believe that it can be fixed by changes in this library. The linked issue magically resolved itself, so perhaps an upgrade to one of the components could fix your issue as well.