Skip to content

Commit b163b28

Browse files
committed
Wrap in do-while
1 parent 7c29575 commit b163b28

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

Objects/moduleobject.c

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -411,30 +411,32 @@ module_from_def_and_spec(
411411
for (cur_slot = def_like->m_slots; cur_slot && cur_slot->slot; cur_slot++) {
412412
// Macro to copy a non-NULL, non-repeatable slot that's unusable with
413413
// PyModuleDef. The destination must be initially NULL.
414-
#define COPY_COMMON_SLOT(SLOT, TYPE, DEST) \
415-
if (!(TYPE)(cur_slot->value)) { \
416-
PyErr_Format( \
417-
PyExc_SystemError, \
418-
"module %s: " #SLOT " must not be NULL", \
419-
name); \
420-
goto error; \
421-
} \
422-
if (original_def) { \
423-
PyErr_Format( \
424-
PyExc_SystemError, \
425-
"module %s: " #SLOT " used with PyModuleDef", \
426-
name); \
427-
goto error; \
428-
} \
429-
if (DEST) { \
430-
PyErr_Format( \
431-
PyExc_SystemError, \
432-
"module %s has more than one " #SLOT " slot", \
433-
name); \
434-
goto error; \
435-
} \
436-
DEST = (TYPE)(cur_slot->value); \
437-
/////////////////////////////////////////////////////////////
414+
#define COPY_COMMON_SLOT(SLOT, TYPE, DEST) \
415+
do { \
416+
if (!(TYPE)(cur_slot->value)) { \
417+
PyErr_Format( \
418+
PyExc_SystemError, \
419+
"module %s: " #SLOT " must not be NULL", \
420+
name); \
421+
goto error; \
422+
} \
423+
if (original_def) { \
424+
PyErr_Format( \
425+
PyExc_SystemError, \
426+
"module %s: " #SLOT " used with PyModuleDef", \
427+
name); \
428+
goto error; \
429+
} \
430+
if (DEST) { \
431+
PyErr_Format( \
432+
PyExc_SystemError, \
433+
"module %s has more than one " #SLOT " slot", \
434+
name); \
435+
goto error; \
436+
} \
437+
DEST = (TYPE)(cur_slot->value); \
438+
} while (0); \
439+
/////////////////////////////////////////////////////////////////
438440
switch (cur_slot->slot) {
439441
case Py_mod_create:
440442
if (create) {

0 commit comments

Comments
 (0)