summaryrefslogtreecommitdiffstats
path: root/Modules/_ssl.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-11-22 02:37:50 (GMT)
committerGitHub <noreply@github.com>2018-11-22 02:37:50 (GMT)
commitb37672daf61740fe1ff9d805f6d74bc5ef04012b (patch)
tree530bb0a89a5de62c1eed68f8b2e616dc24cdc497 /Modules/_ssl.c
parent2ff8fb7639a86757c00a7cbbe7da418fffec3870 (diff)
downloadcpython-b37672daf61740fe1ff9d805f6d74bc5ef04012b.zip
cpython-b37672daf61740fe1ff9d805f6d74bc5ef04012b.tar.gz
cpython-b37672daf61740fe1ff9d805f6d74bc5ef04012b.tar.bz2
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);"
Diffstat (limited to 'Modules/_ssl.c')
-rw-r--r--Modules/_ssl.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 93498f4..85819f5 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);