Re: [Pyobjc-dev] Problem with pyObjC and Swift
Brought to you by:
ronaldoussoren
From: Wim L. <wi...@om...> - 2018-02-27 02:02:47
|
On Thu, 30 Mar 2017 at 10:27 Georg Seifert <geo...@gm...> wrote: > I have an app written in ObjectiveC. It allows loading plugins from third parties. Most of those are written in python, some in ObjectiveC. Now someone tries to write on in Swift. That plugin works as expected but all the python plugin don't work any more and crash the app. At least when the plugin is build with Xcode 8 and Swift 3. Compiling it on Xcode 7 (macOS 10.10) works fine. Running the Xcode 8 version on 10.10 crashes, too. > > The app links agains the system python framework. > > Anyone has knows anything about this? > > Thanks > Georg Seifert > > p.s. I get backtraces like this: > > Calling a method on an python object inheriting from NSObject > > #0 0x0000000100a56ed7 in ___lldb_unnamed_function679$$Python () > #1 0x0000000100a584f1 in PyDict_SetItemString () > #2 0x00000001098319a5 in PyObjCClass_CheckMethodList ( > #3 0x0000000109832543 in ___lldb_unnamed_function453$$_objc.so () > #4 0x0000000100aa3238 in ___lldb_unnamed_function1431$$Python () > #5 0x0000000100aa9d8c in PyEval_EvalFrameEx () I recently ran into this same problem (I have an app that uses PyObjC, and elsewhere in the app --- code that never interacts with python --- there are some Swift classes). As far as I can tell, this is a bug in the ancient version of PyObjC that Apple ships: it fails to check for an exception return from PyObjCSelector_NewNative(), and crashes because that function can't handle some selectors registered by Swift. In my case the first problem it hits is a Swift extension on NSDictionary from libswiftFoundation.dylib. Although this bug exists in PyObjC 2.5.1 (the version shipped with MacOSX as of 10.13.1), it looks like it was fixed as far back as PyObjC 3.x. |