PyQt5 returnPressed.connect win32 exception

def keyPressEvent(self, event):
    key = event.key()
    if key == Qt.Key_Escape:
        print('esc')
        QCoreApplication.quit()
    elif key == Qt.RightArroww:
        print('->')
    elif key == Qt.LeftArrow:
        print('<-')

I delete the code and the exception problem was vanished.