Repository: ipython/ipython

Issue:
7.27.0 Qt6 support throws exception with PyQt6 on Windows
PyQt6 6.1.1 / Windows 10 20H2
```python
PS C:\work> .\venv\pyqt6\Scripts\Activate.ps1
(pyqt6) PS C:\work> ipython
Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.27.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %gui qt

In [2]: Traceback (most recent call last):
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\work\venv\pyqt6\Scripts\ipython.exe\__main__.py", line 7, in <module>
    sys.exit(start_ipython())
  File "c:\work\venv\pyqt6\lib\site-packages\IPython\__init__.py", line 126, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "c:\work\venv\pyqt6\lib\site-packages\traitlets\config\application.py", line 845, in launch_instance
    app.start()
  File "c:\work\venv\pyqt6\lib\site-packages\IPython\terminal\ipapp.py", line 356, in start
    self.shell.mainloop()
  File "c:\work\venv\pyqt6\lib\site-packages\IPython\terminal\interactiveshell.py", line 564, in mainloop
    self.interact()
  File "c:\work\venv\pyqt6\lib\site-packages\IPython\terminal\interactiveshell.py", line 547, in interact
    code = self.prompt_for_code()
    text = self.pt_app.prompt(
  File "c:\work\venv\pyqt6\lib\site-packages\prompt_toolkit\shortcuts\prompt.py", line 1020, in prompt
    return self.app.run(
  File "c:\work\venv\pyqt6\lib\site-packages\prompt_toolkit\application\application.py", line 891, in run
    return loop.run_until_complete(
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 603, in run_until_complete
    self.run_forever()
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 570, in run_forever
    self._run_once()
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 1823, in _run_once
    event_list = self._selector.select(timeout)
  File "c:\work\venv\pyqt6\lib\site-packages\prompt_toolkit\eventloop\inputhook.py", line 117, in select
    self.inputhook(InputHookContext(self._r, input_is_ready))
  File "c:\work\venv\pyqt6\lib\site-packages\IPython\terminal\pt_inputhooks\qt.py", line 67, in inputhook
    event_loop.exec_()
AttributeError: 'QEventLoop' object has no attribute 'exec_'
```

Other combinations tested to **not** have this issue:
1) PySide6 6.1.2 / Windows 10 20H2 / Python 3.8.10
2) PyQt6 6.1.1 / Ubuntu 20.04 / Python 3.8.10


Discussion:
🤦🏻 I missed the win32 branch, sorry about that.  

Resolving patch:
diff --git a/IPython/terminal/pt_inputhooks/qt.py b/IPython/terminal/pt_inputhooks/qt.py
--- a/IPython/terminal/pt_inputhooks/qt.py
+++ b/IPython/terminal/pt_inputhooks/qt.py
@@ -64,7 +64,7 @@ def inputhook(context):
         timer.timeout.connect(event_loop.quit)
         while not context.input_is_ready():
             timer.start(50)  # 50 ms
-            event_loop.exec_()
+            _exec(event_loop)
             timer.stop()
     else:
         # On POSIX platforms, we can use a file descriptor to quit the event


Test patch: