Skip to content

Commit 5ddff7a

Browse files
committed
Fixed refcounting in ctests; Fixed issue where I was using the wrong format specifier for str/None; all issues brought up by coderabbit
1 parent ad295f2 commit 5ddff7a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

ctest/base_ctest.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ PG_CTEST(test__pg_is_int_tuple_nominal)(PyObject *self, PyObject *_null) {
2222
TEST_ASSERT_EQUAL(1, _pg_is_int_tuple(arg2));
2323
TEST_ASSERT_EQUAL(1, _pg_is_int_tuple(arg3));
2424

25+
Py_DECREF(arg1);
26+
Py_DECREF(arg2);
27+
Py_DECREF(arg3);
28+
2529
Py_RETURN_NONE;
2630
}
2731

@@ -31,14 +35,18 @@ PG_CTEST(test__pg_is_int_tuple_nominal)(PyObject *self, PyObject *_null) {
3135
PG_CTEST(test__pg_is_int_tuple_failureModes)(PyObject *self, PyObject *_null) {
3236
PyObject *arg1 =
3337
Py_BuildValue("(sss)", (char *)"Larry", (char *)"Moe", (char *)"Curly");
34-
PyObject *arg2 = Py_BuildValue("(sss)", (char *)NULL, (char *)NULL,
38+
PyObject *arg2 = Py_BuildValue("(zzz)", (char *)NULL, (char *)NULL,
3539
(char *)NULL); // tuple of None's
3640
PyObject *arg3 = Py_BuildValue("(OOO)", arg1, arg2, arg1);
3741

3842
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg1));
3943
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg2));
4044
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg3));
4145

46+
Py_DECREF(arg1);
47+
Py_DECREF(arg2);
48+
Py_DECREF(arg3);
49+
4250
Py_RETURN_NONE;
4351
}
4452

@@ -54,6 +62,10 @@ PG_CTEST(test__pg_is_int_tuple_floats)(PyObject *self, PyObject *_null) {
5462
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg2));
5563
TEST_ASSERT_EQUAL(0, _pg_is_int_tuple(arg3));
5664

65+
Py_DECREF(arg1);
66+
Py_DECREF(arg2);
67+
Py_DECREF(arg3);
68+
5769
Py_RETURN_NONE;
5870
}
5971

0 commit comments

Comments
 (0)