ronaldoussoren / pyobjc

The Python <-> Objective-C Bridge with bindings for macOS frameworks
https://pyobjc.readthedocs.io
563 stars 47 forks source link

Exception when initializing pyobjc #576

Open schriftgestalt opened 1 year ago

schriftgestalt commented 1 year ago

In my app (Mac app written in objectiveC) that uses python/pyobjc for plugins and scripting I get this exception the first time python is used:

Thread 1: "assertion failed: 'UINSServiceViewController requires Marzipan' in +[UINSServiceViewController initialize] on line 258 of file /AppleInternal/Library/BuildRoots/a0876c02-1788-11ed-b9c4-96898e02b808/Library/Caches/com.apple.xbs/Sources/ViewBridge/UINSServiceViewController.m"

That is not a big problem as the exception is caught somewhere by the system. It is only annoying when I start the app with active breakpoints. But the error looks so unusual that I though I report it anyway.

This is the traceback in Xcode

#0  0x000000018977bdc8 in objc_exception_throw ()
#1  0x0000000189a5c0bc in -[NSException raise] ()
#2  0x0000000190d942cc in +[UINSServiceViewController initialize] ()
#3  0x000000018976bbe4 in CALLING_SOME_+initialize_METHOD ()
#4  0x000000018976b830 in initializeNonMetaClass ()
#5  0x000000018976b250 in initializeAndMaybeRelock(objc_class*, objc_object*, mutex_tt<false>&, bool) ()
#6  0x000000018976afe8 in lookUpImpOrForward ()
#7  0x000000018976a8e4 in _objc_msgSend_uncached ()
#8  0x0000000189770e50 in resolveMethod_locked(objc_object*, objc_selector*, objc_class*, int) ()
#9  0x0000000189771fc0 in class_getInstanceMethod ()
#10 0x000000010fd0adf4 in PyObjCMetaClass_TryResolveSelector ()
#11 0x000000010fd0b208 in class_getattro ()
#12 0x000000011def8eac in PyObject_GetAttrString ()
#13 0x000000010fd0ba40 in class_setattro ()
#14 0x000000011def89e0 in PyObject_SetAttr ()
#15 0x000000011def9194 in PyObject_SetAttrString ()
#16 0x000000010fd0abcc in PyObjCClass_New ()
#17 0x000000010fcbba64 in PyObjC_GetClassList ()
#18 0x000000010fd08424 in loadBundle ()
#19 0x000000011def1784 in cfunction_call ()
#20 0x000000011de8cd78 in _PyObject_MakeTpCall ()
#21 0x000000011dfb406c in _PyEval_EvalFrameDefault ()
#22 0x000000011dfa5f7c in PyEval_EvalCode ()
#23 0x000000011dfa07f4 in builtin_exec ()
#24 0x000000011def2194 in cfunction_vectorcall_FASTCALL_KEYWORDS ()
#25 0x000000011dfb6b50 in _PyEval_EvalFrameDefault ()
#26 0x000000011dfb99ec in _PyEval_Vector ()
#27 0x000000011de8f808 in object_vacall ()
#28 0x000000011de8f638 in PyObject_CallMethodObjArgs ()
#29 0x000000011dff24ac in PyImport_ImportModuleLevelObject ()
#30 0x000000011dfaff0c in _PyEval_EvalFrameDefault ()
#31 0x000000011dfa5f7c in PyEval_EvalCode ()
#32 0x000000011e01f39c in pyrun_file ()
#33 0x000000011e023714 in PyRun_FileExFlags ()
#34 0x00000001096f2930 in pyobjc_main [inlined] at …/Glyphs3/Plugin/pythonWrapper/pythonWrapper/main.m:481
#35 0x00000001096f2360 in _py2app_bundle_load at …/Glyphs3/Plugin/pythonWrapper/pythonWrapper/main.m:581

(macOS 12.7, Xcode 14.0.1, python3.11, pyobjc10.0)

ronaldoussoren commented 11 months ago

That's the joy of using a newer macOS version where some macCatalist classes are visible even in code that isn't using macCatalyst itself.

I've not yet found a way to avoid triggering this error other than reducing the chance by ignoring all classes whose name starts with ("NSUI").