Skip to content

Commit

Permalink
More work on test coverage
Browse files Browse the repository at this point in the history
Focus was on increasing test coverage for the callable stub
in libffi_support.m, with some minor changes elsewhere.
  • Loading branch information
ronaldoussoren committed Jan 3, 2025
1 parent 650587a commit a513505
Show file tree
Hide file tree
Showing 19 changed files with 2,180 additions and 98 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ borrowed references).

* :issue:`632`: fix broken bindings for ``CGWindowListCreateImageFromArray``.

* The private ``__is_magic`` attribute on :class:`objc.objc_object` has
been renamed to ``__pyobjc_magic_coookie__``.

* Various fixes to edge case behaviour that were found while improving
test coverage.

Version 10.3.2
--------------

Expand Down
12 changes: 6 additions & 6 deletions pyobjc-core/Lib/objc/_convenience_nsobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,37 @@ def nsobject_hash(self, _max=sys.maxsize, _const=((sys.maxsize + 1) * 2)):


def nsobject__eq__(self, other):
if self.__is_magic():
if self.__pyobjc_magic_coookie__():
return self is other
return bool(self.isEqualTo_(other))


def nsobject__ne__(self, other):
if self.__is_magic():
if self.__pyobjc_magic_coookie__():
return self is not other
return bool(self.isNotEqualTo_(other))


def nsobject__gt__(self, other):
if self.__is_magic():
if self.__pyobjc_magic_coookie__():
return NotImplemented
return bool(self.isGreaterThan_(other))


def nsobject__ge__(self, other):
if self.__is_magic():
if self.__pyobjc_magic_coookie__():
return NotImplemented
return bool(self.isGreaterThanOrEqualTo_(other))


def nsobject__lt__(self, other):
if self.__is_magic():
if self.__pyobjc_magic_coookie__():
return NotImplemented
return bool(self.isLessThan_(other))


def nsobject__le__(self, other):
if self.__is_magic():
if self.__pyobjc_magic_coookie__():
return NotImplemented
return bool(self.isLessThanOrEqualTo_(other))

Expand Down
2 changes: 1 addition & 1 deletion pyobjc-core/Modules/objc/block_support.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
return NULL;
}

if (block->flags & BLOCK_HAS_SIGNATURE) {
if ((block->flags & BLOCK_HAS_SIGNATURE) != 0) {
const char* signature_loc = (void*)(block->descriptor);
signature_loc += sizeof(unsigned long) * 2;
if (block->flags & BLOCK_HAS_COPY_DISPOSE) {
Expand Down
30 changes: 22 additions & 8 deletions pyobjc-core/Modules/objc/instance-var.m
Original file line number Diff line number Diff line change
Expand Up @@ -295,20 +295,22 @@

if (name) {
self->name = PyObjCUtil_Strdup(name);
if (self->name == NULL) {
return -1;
if (self->name == NULL) { // LCOV_BR_EXCL_LINE
return -1; // LCOV_EXCL_LINE
}

} else {
self->name = NULL;
}

char* type_copy = PyObjCUtil_Strdup(type);
if (type_copy == NULL) {
if (type_copy == NULL) { // LCOV_BR_EXCL_LINE
// LCOV_EXCL_START
if (name) {
PyMem_Free(self->name);
}
return -1;
// LCOV_EXCL_STOP
}
self->type = type_copy;
if (isOutletObj) {
Expand Down Expand Up @@ -351,9 +353,11 @@

if (self->name == NULL) {
self->name = PyObjCUtil_Strdup(name);
if (self->name == NULL) {
if (self->name == NULL) { // LCOV_BR_EXCL_LINE
// LCOV_EXCL_START
PyErr_NoMemory();
return NULL;
// LCOV_EXCL_STOP
}
}

Expand Down Expand Up @@ -388,8 +392,8 @@
result ^= 0x20;
}

if (result == -1) {
result = -2;
if (result == -1) { // LCOV_BR_EXCL_LINE
result = -2; // LCOV_EXCL_LINE
}

return result;
Expand All @@ -410,17 +414,27 @@
&& (strcmp(PyObjCInstanceVariable_GetName(a),
PyObjCInstanceVariable_GetName(b))
== 0);
} else {
same = 0;
}

if (PyObjCInstanceVariable_GetType(a) == NULL) {
/* XXX: ..._GetType cannot be NULL */
if (PyObjCInstanceVariable_GetType(a) == NULL) { // LCOV_BR_EXCL_LINE
// LCOV_EXCL_START
if (PyObjCInstanceVariable_GetType(b) != NULL) {
same = 0;
}
} else if (PyObjCInstanceVariable_GetType(b) != NULL) {
// LCOV_EXCL_STOP
} else if (PyObjCInstanceVariable_GetType(b) != NULL) { // LCOV_BR_EXCL_LINE
same = same
&& (strcmp(PyObjCInstanceVariable_GetType(a),
PyObjCInstanceVariable_GetType(b))
== 0);
} else {
// LCOV_EXCL_START
/* a's type is not null while b's type is */
same = 0;
// LCOV_EXCL_STOP
}

if (PyObjCInstanceVariable_IsSlot(a) != PyObjCInstanceVariable_IsSlot(b)) {
Expand Down
Loading

0 comments on commit a513505

Please sign in to comment.