mirror of
https://github.com/python/cpython.git
synced 2026-03-06 13:00:50 +00:00
Avoid mixing declarations and code in the C API to fix the compiler
warning: "ISO C90 forbids mixed declarations and code"
[-Werror=declaration-after-statement].
(cherry picked from commit 90e7230073)
This commit is contained in:
parent
5f24acdca0
commit
a3d2ce95d1
4 changed files with 16 additions and 9 deletions
|
|
@ -37,9 +37,11 @@ PyAPI_FUNC(Py_ssize_t) _PyWeakref_GetWeakrefCount(PyWeakReference *head);
|
|||
PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self);
|
||||
|
||||
static inline PyObject* PyWeakref_GET_OBJECT(PyObject *ref_obj) {
|
||||
PyWeakReference *ref;
|
||||
PyObject *obj;
|
||||
assert(PyWeakref_Check(ref_obj));
|
||||
PyWeakReference *ref = _Py_CAST(PyWeakReference*, ref_obj);
|
||||
PyObject *obj = ref->wr_object;
|
||||
ref = _Py_CAST(PyWeakReference*, ref_obj);
|
||||
obj = ref->wr_object;
|
||||
// Explanation for the Py_REFCNT() check: when a weakref's target is part
|
||||
// of a long chain of deallocations which triggers the trashcan mechanism,
|
||||
// clearing the weakrefs can be delayed long after the target's refcount
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue