Skip to content
Prev Previous commit
Next Next commit
fix format
  • Loading branch information
corona10 committed May 2, 2023
commit 2f4ee5f9dc102e60341cee41df9ca02826eb4760
20 changes: 10 additions & 10 deletions Modules/_testcapi/immortal.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test_immortal_bool(PyObject *self, PyObject *Py_UNUSED(ignored))
PyObject* obj = objects[i];
if (!_Py_IsImmortal(obj)) {
PyErr_Format(PyExc_RuntimeError, "%R should be the immportal object.", obj);
return NULL;
return NULL;
}
Py_ssize_t old_count = Py_REFCNT(obj);
for (int i = 0; i < 10000; i++) {
Expand All @@ -18,7 +18,7 @@ test_immortal_bool(PyObject *self, PyObject *Py_UNUSED(ignored))
Py_ssize_t current_count = Py_REFCNT(obj);
if (old_count != current_count) {
PyErr_SetString(PyExc_RuntimeError, "Reference count should not be changed.");
return NULL;
return NULL;
}
}
Py_RETURN_NONE;
Expand All @@ -30,7 +30,7 @@ test_immortal_none(PyObject *self, PyObject *Py_UNUSED(ignored))
PyObject* none = Py_None;
if (!_Py_IsImmortal(none)) {
PyErr_Format(PyExc_RuntimeError, "%R should be the immportal object.", none);
return NULL;
return NULL;
}
Py_ssize_t old_count = Py_REFCNT(none);
for (int i = 0; i < 10000; i++) {
Expand All @@ -39,7 +39,7 @@ test_immortal_none(PyObject *self, PyObject *Py_UNUSED(ignored))
Py_ssize_t current_count = Py_REFCNT(none);
if (old_count != current_count) {
PyErr_SetString(PyExc_RuntimeError, "Reference count should not be changed.");
return NULL;
return NULL;
}
Py_RETURN_NONE;
}
Expand All @@ -51,7 +51,7 @@ test_immortal_small_ints(PyObject *self, PyObject *Py_UNUSED(ignored))
PyObject *small_int = PyLong_FromLong(i);
if (!_Py_IsImmortal(small_int)) {
PyErr_Format(PyExc_RuntimeError, "Small int(%d) object should be the immportal object.", i);
return NULL;
return NULL;
}
Py_ssize_t old_count = Py_REFCNT(small_int);
for (int i = 0; i < 10000; i++) {
Expand All @@ -60,7 +60,7 @@ test_immortal_small_ints(PyObject *self, PyObject *Py_UNUSED(ignored))
Py_ssize_t current_count = Py_REFCNT(small_int);
if (old_count != current_count) {
PyErr_Format(PyExc_RuntimeError, "Reference count of %d should not be changed.", i);
return NULL;
return NULL;
}
}
Py_RETURN_NONE;
Expand All @@ -72,7 +72,7 @@ test_immortal_ellipsis(PyObject *self, PyObject *Py_UNUSED(ignored))
PyObject* ellipsis = Py_Ellipsis;
if (!_Py_IsImmortal(ellipsis)) {
PyErr_SetString(PyExc_RuntimeError, "Ellipsis object should be the immportal object.");
return NULL;
return NULL;
}
Py_ssize_t old_count = Py_REFCNT(ellipsis);
for (int i = 0; i < 10000; i++) {
Expand All @@ -81,7 +81,7 @@ test_immortal_ellipsis(PyObject *self, PyObject *Py_UNUSED(ignored))
Py_ssize_t current_count = Py_REFCNT(ellipsis);
if (old_count != current_count) {
PyErr_SetString(PyExc_RuntimeError, "Reference count should not be changed.");
return NULL;
return NULL;
}
Py_RETURN_NONE;
}
Expand All @@ -97,9 +97,9 @@ static PyMethodDef test_methods[] = {

int
_PyTestCapi_Init_Immortal(PyObject *mod)
{
{
if (PyModule_AddFunctions(mod, test_methods) < 0) {
return -1;
}
return 0;
}
}