From b37672daf61740fe1ff9d805f6d74bc5ef04012b Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 22 Nov 2018 03:37:50 +0100 Subject: bpo-35059: Cleanup usage of Python macros (GH-10648) Don't pass complex expressions but regular variables to Python macros. * _datetimemodule.c: split single large "if" into two "if" in date_new(), time_new() and datetime_new(). * _pickle.c, load_extension(): flatten complex "if" expression into more regular C code. * _ssl.c: addbool() now uses a temporary bool_obj to only evaluate the value once. * weakrefobject.c: replace "Py_INCREF(result = proxy);" with "result = proxy; Py_INCREF(result);" --- Modules/_ssl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Modules/_ssl.c') diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 93498f4756..85819f5b05 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -5983,9 +5983,12 @@ PyInit__ssl(void) PyModule_AddIntConstant(m, "PROTO_TLSv1_2", PY_PROTO_TLSv1_2); PyModule_AddIntConstant(m, "PROTO_TLSv1_3", PY_PROTO_TLSv1_3); -#define addbool(m, v, b) \ - Py_INCREF((b) ? Py_True : Py_False); \ - PyModule_AddObject((m), (v), (b) ? Py_True : Py_False); +#define addbool(m, key, value) \ + do { \ + PyObject *bool_obj = (value) ? Py_True : Py_False; \ + Py_INCREF(bool_obj); \ + PyModule_AddObject((m), (key), bool_obj); \ + } while (0) #if HAVE_SNI addbool(m, "HAS_SNI", 1); -- cgit v1.2.1