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
bpo-28254: Formatting.
  • Loading branch information
scoder committed Apr 28, 2021
commit e5f0077f7575d10fe91934ac01441fd9d6b47868
20 changes: 15 additions & 5 deletions Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,29 @@ test_gc_control(PyObject *self, PyObject *Py_UNUSED(ignored))

old_state = PyGC_Enable();
msg = "Enable(1)";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bugs are unlikely. IMO using assert() is good enough for _testcapi tests. You can leave the code as it is ;-)

See for example test_refcount_funcs() which uses assert().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that assertions can be compiled out, which is decidedly not intended here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general yes, but _testcapimodule.c starts with:

/* Always enable assertions */
#undef NDEBUG

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know! I'd keep the test as it is though. It doesn't really hurt, I think.

if (old_state != orig_enabled) goto failed;
if (old_state != orig_enabled) {
goto failed;
}
msg = "IsEnabled(1)";
if (!PyGC_IsEnabled()) {
goto failed;
}

old_state = PyGC_Disable();
msg = "disable(2)";
if (!old_state) goto failed;
if (!old_state) {
goto failed;
}
msg = "IsEnabled(2)";
if (PyGC_IsEnabled()) {
goto failed;
}

old_state = PyGC_Enable();
msg = "enable(3)";
if (old_state) goto failed;
if (old_state) {
goto failed;
}
msg = "IsEnabled(3)";
if (!PyGC_IsEnabled()) {
goto failed;
Expand All @@ -178,9 +184,13 @@ test_gc_control(PyObject *self, PyObject *Py_UNUSED(ignored))
if (!orig_enabled) {
old_state = PyGC_Disable();
msg = "disable(4)";
if (old_state) goto failed;
if (old_state) {
goto failed;
}
msg = "IsEnabled(4)";
if (PyGC_IsEnabled()) goto failed;
if (PyGC_IsEnabled()) {
goto failed;
}
}

Py_RETURN_NONE;
Expand Down