Skip to content

Commit 4a1003c

Browse files
committed
use a local macro
1 parent 24f47a1 commit 4a1003c

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

Modules/_cursesmodule.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -236,22 +236,6 @@ static char *CURSES_SCREEN_ENCODING = NULL;
236236
CHECK_RET_CODE(rc); \
237237
} while (0)
238238

239-
/*
240-
* Add an integral constant to a module; on error, jump to the 'error' label.
241-
*
242-
* Parameters
243-
*
244-
* PyObject * MODULE The module object to alter.
245-
* const char * NAME The constant name.
246-
* int or long VALUE The constant value.
247-
*/
248-
#define MODULE_ADD_INT_CONSTANT(MODULE, NAME, VALUE) \
249-
do { \
250-
long value = (long)(VALUE); \
251-
int rc = PyModule_AddIntConstant((MODULE), (NAME), value); \
252-
CHECK_RET_CODE(rc); \
253-
} while (0)
254-
255239
/* Utility Functions */
256240

257241
/*
@@ -4033,10 +4017,19 @@ update_lines_cols(PyObject *private_module)
40334017
if (exposed_module == NULL) {
40344018
return 0;
40354019
}
4020+
#define MODULE_ADD_INT_CONSTANT(MODULE, NAME, VALUE) \
4021+
do { \
4022+
if (PyModule_AddIntConstant((MODULE), (NAME), (long)(VALUE)) < 0) { \
4023+
goto error; \
4024+
} \
4025+
} while (0)
4026+
40364027
MODULE_ADD_INT_CONSTANT(exposed_module, "LINES", LINES);
40374028
MODULE_ADD_INT_CONSTANT(private_module, "LINES", LINES);
40384029
MODULE_ADD_INT_CONSTANT(exposed_module, "COLS", COLS);
40394030
MODULE_ADD_INT_CONSTANT(private_module, "COLS", COLS);
4031+
#undef MODULE_ADD_INT_CONSTANT
4032+
40404033
Py_DECREF(exposed_module);
40414034
return 1;
40424035

0 commit comments

Comments
 (0)