From d9a654c558623c77e7dd393a1a89572fb2cfaa81 2021-02-02 18:08:22 From: Matthias Bussonnier Date: 2021-02-02 18:08:22 Subject: [PATCH] Backport PR #12804: Add explicit argtype counting, required for osx-arm64. --- diff --git a/IPython/terminal/pt_inputhooks/osx.py b/IPython/terminal/pt_inputhooks/osx.py index 53f4e38..a3131ee 100644 --- a/IPython/terminal/pt_inputhooks/osx.py +++ b/IPython/terminal/pt_inputhooks/osx.py @@ -77,24 +77,42 @@ kCFRunLoopCommonModes = void_p.in_dll(CoreFoundation, 'kCFRunLoopCommonModes') def _NSApp(): """Return the global NSApplication instance (NSApp)""" + objc.objc_msgSend.argtypes = [void_p, void_p] return msg(C('NSApplication'), n('sharedApplication')) def _wake(NSApp): """Wake the Application""" - event = msg(C('NSEvent'), - n('otherEventWithType:location:modifierFlags:' - 'timestamp:windowNumber:context:subtype:data1:data2:'), - 15, # Type - 0, # location - 0, # flags - 0, # timestamp - 0, # window - None, # context - 0, # subtype - 0, # data1 - 0, # data2 + objc.objc_msgSend.argtypes = [ + void_p, + void_p, + void_p, + void_p, + void_p, + void_p, + void_p, + void_p, + void_p, + void_p, + void_p, + ] + event = msg( + C("NSEvent"), + n( + "otherEventWithType:location:modifierFlags:" + "timestamp:windowNumber:context:subtype:data1:data2:" + ), + 15, # Type + 0, # location + 0, # flags + 0, # timestamp + 0, # window + None, # context + 0, # subtype + 0, # data1 + 0, # data2 ) + objc.objc_msgSend.argtypes = [void_p, void_p, void_p, void_p] msg(NSApp, n('postEvent:atStart:'), void_p(event), True) @@ -106,6 +124,7 @@ def _input_callback(fdref, flags, info): CFFileDescriptorInvalidate(fdref) CFRelease(fdref) NSApp = _NSApp() + objc.objc_msgSend.argtypes = [void_p, void_p, void_p] msg(NSApp, n('stop:'), NSApp) _wake(NSApp) @@ -128,6 +147,7 @@ def inputhook(context): """Inputhook for Cocoa (NSApp)""" NSApp = _NSApp() _stop_on_read(context.fileno()) + objc.objc_msgSend.argtypes = [void_p, void_p] msg(NSApp, n('run')) if not _triggered.is_set(): # app closed without firing callback,