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);"
This commit is contained in:
Victor Stinner 2018-11-22 03:37:50 +01:00 committed by GitHub
parent 2ff8fb7639
commit b37672daf6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 109 additions and 85 deletions

View file

@ -833,7 +833,8 @@ PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
to avoid violating the invariants of the list
of weakrefs for ob. */
Py_DECREF(result);
Py_INCREF(result = proxy);
result = proxy;
Py_INCREF(result);
goto skip_insert;
}
prev = ref;