Skip to content

Commit

Permalink
Generalize workaround for #271 for more placeholder classes
Browse files Browse the repository at this point in the history
Fixes #625
  • Loading branch information
ronaldoussoren committed Oct 27, 2024
1 parent 093b605 commit 766cb51
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Version 10.3.2

Fix by user rndblnch on github

* :issue:`625`: Fix crash for calling ``NSIndexSet.alloc().initWithIndex_(0)``

This "fix" is a workaround for what appears to be a bug in Foundation.

Version 10.3.1
--------------

Expand Down
9 changes: 5 additions & 4 deletions pyobjc-core/Modules/objc/objc-class.m
Original file line number Diff line number Diff line change
Expand Up @@ -2659,15 +2659,16 @@ static Class _Nullable objc_metaclass_locate(PyObject* meta_class)
PyType_Ready((PyTypeObject*)result);
}

if (strcmp(className, "_NSPlaceholderData") == 0) {
/* XXX */
if (strncmp(className, "_NSPlaceholder", sizeof("_NSPlaceholder")-1) == 0) {
/* Workaround for an issue on macOS 10.15: For some
* reason the call to class_getInstanceVariable crashes
* when called early in the process, likely due to an
* incompletely initialized class.
*
* The workaround is hardcoded for this specific class
* to avoid issues with other magic classes.
* The issue is more widespread in later versions of the OS,
* and seems to be related to rewriting Foundation in Swift.
*
* Issues: #271, #625
*/
[objc_class class];
}
Expand Down

0 comments on commit 766cb51

Please sign in to comment.