Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Longer version
  • Loading branch information
sobolevn committed Oct 9, 2023
commit 4235ee8879cdb1581f06c63c1929c52bcfcde913
17 changes: 11 additions & 6 deletions Modules/_testcapi/set.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,26 @@ test_frozenset_add_in_capi(PyObject *self, PyObject *Py_UNUSED(obj))
}
PyObject *num = PyLong_FromLong(1);
if (num == NULL) {
return NULL;
goto error;
}
if (PySet_Add(fs, num) < 0) {
return NULL;
goto error;
}
int contains = PySet_Contains(fs, num);
Py_DECREF(num);
if (contains < 0) {
return NULL;
goto error;
}
else if (contains == 0) {
PyErr_SetString(PyExc_ValueError, "set does not contain expected value");
return NULL;
goto unexpected;
}
Py_RETURN_NONE;

unexpected:
PyErr_SetString(PyExc_ValueError, "set does not contain expected value");
error:
Py_DECREF(fs);
Py_XDECREF(num);
return NULL;
}

static PyMethodDef test_methods[] = {
Expand Down