Skip to content

Commit d7d08ca

Browse files
Fixed the asserts in PyAwaitable_AddAwait, PyAwaitable_DeferAwait, and PyAwaitable_SetResult (#84)
Signed-off-by: AraHaan <[email protected]> Co-authored-by: Peter Bierma <[email protected]>
1 parent fb160c7 commit d7d08ca

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Added `PyAwaitable_AddExpr`.
6+
- Fix assertion failures when running in debug mode.
67

78
## [2.0.1] - 2025-06-15
89

src/_pyawaitable/awaitable.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ PyAwaitable_AddAwait(
160160
)
161161
{
162162
PyAwaitableObject *aw = (PyAwaitableObject *) self;
163-
assert(Py_IS_TYPE(Py_TYPE(self), PyAwaitable_GetType()));
163+
assert(Py_IS_TYPE(self, PyAwaitable_GetType()));
164164
if (coro == NULL) {
165165
PyErr_SetString(
166166
PyExc_ValueError,
@@ -231,7 +231,7 @@ _PyAwaitable_API(int)
231231
PyAwaitable_DeferAwait(PyObject * awaitable, PyAwaitable_Defer cb)
232232
{
233233
PyAwaitableObject *aw = (PyAwaitableObject *) awaitable;
234-
assert(Py_IS_TYPE(Py_TYPE(awaitable), PyAwaitable_GetType()));
234+
assert(Py_IS_TYPE(awaitable, PyAwaitable_GetType()));
235235
pyawaitable_callback *aw_c = PyMem_Malloc(sizeof(pyawaitable_callback));
236236
if (aw_c == NULL) {
237237
PyErr_NoMemory();
@@ -256,7 +256,7 @@ _PyAwaitable_API(int)
256256
PyAwaitable_SetResult(PyObject * awaitable, PyObject * result)
257257
{
258258
PyAwaitableObject *aw = (PyAwaitableObject *) awaitable;
259-
assert(Py_IS_TYPE(Py_TYPE(awaitable), PyAwaitable_GetType()));
259+
assert(Py_IS_TYPE(awaitable, PyAwaitable_GetType()));
260260
aw->aw_result = Py_NewRef(result);
261261
return 0;
262262
}

0 commit comments

Comments
 (0)