8000 Fix formatting · python/cpython@40d99d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 40d99d4

Browse files
committed
Fix formatting
1 parent 0021bc5 commit 40d99d4

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

Include/internal/pycore_weakref.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ extern "C" {
1414

1515
#ifdef Py_GIL_DISABLED
1616

17-
#define WEAKREF_LIST_LOCK(obj) _PyInterpreterState_GET()->weakref_locks[((uintptr_t) obj) % NUM_WEAKREF_LIST_LOCKS]
17+
#define WEAKREF_LIST_LOCK(obj) \
18+
_PyInterpreterState_GET() \
19+
->weakref_locks[((uintptr_t)obj) % NUM_WEAKREF_LIST_LOCKS]
1820

19-
#define LOCK_WEAKREFS(obj) PyMutex_LockFlags(&WEAKREF_LIST_LOCK(obj), _Py_LOCK_DONT_DETACH)
21+
#define LOCK_WEAKREFS(obj) \
22+
PyMutex_LockFlags(&WEAKREF_LIST_LOCK(obj), _Py_LOCK_DONT_DETACH)
2023
#define UNLOCK_WEAKREFS(obj) PyMutex_Unlock(&WEAKREF_LIST_LOCK(obj))
2124

2225
#else
@@ -58,7 +61,7 @@ static inline PyObject* _PyWeakref_GET_REF(PyObject *ref_obj)
5861
return NULL;
5962
}
6063
assert(Py_REFCNT(obj) > 0);
61-
return Py_NewRef(obj);
64+
return Py_NewRef(obj);
6265
#else
6366
PyObject *obj = _Py_atomic_load_ptr(&ref->wr_object);
6467
if (obj == Py_None) {

Objects/weakrefobject.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ clear_weakref_lock_held(PyWeakReference *self, PyObject **callback)
138138
if (_Py_atomic_load_ptr(&self->wr_object) != Py_None) {
139139
PyWeakReference **list = GET_WEAKREFS_LISTPTR(self->wr_object);
140140
if (*list == self)
141-
/* If 'self' is the end of the list (and thus self->wr_next == NULL)
142-
then the weakref list itself (and thus the value of *list) will
143-
end up being set to NULL. */
141+
/* If 'self' is the end of the list (and thus self->wr_next ==
142+
NULL) then the weakref list itself (and thus the value of *list)
143+
will end up being set to NULL. */
144144
_Py_atomic_store_ptr(list, self->wr_next);
145145
_Py_atomic_store_ptr(&self->wr_object, Py_None);
146146
if (self->wr_prev != NULL)
@@ -430,7 +430,8 @@ insert_head(PyWeakReference *newref, PyWeakReference **list)
430430
* weakref
431431
*/
432432
static PyWeakReference *
433-
try_reuse_basic_ref(PyWeakReference *ref, PyWeakReference *proxy, PyTypeObject *type, PyObject *callback)
433+
try_reuse_basic_ref(PyWeakReference *ref, PyWeakReference *proxy,
434+
PyTypeObject *type, PyObject *callback)
434435
{
435436
if (callback != NULL) {
436437
return NULL;
@@ -488,10 +489,12 @@ get_prev(PyWeakReference *newref, PyWeakReference *ref, PyWeakReference *proxy)
488489
return (proxy == NULL) ? ref : proxy;
489490
}
490491

491-
typedef PyWeakReference * (*weakref_alloc_fn)(PyTypeObject *, PyObject *, PyObject *);
492+
typedef PyWeakReference *(*weakref_alloc_fn)(PyTypeObject *, PyObject *,
493+
PyObject *);
492494

493495
static PyWeakReference *
494-
get_or_create_weakref(PyTypeObject *type, weakref_alloc_fn allocate, PyObject *obj, PyObject *callback)
496+
get_or_create_weakref(PyTypeObject *type, weakref_alloc_fn allocate,
497+
PyObject *obj, PyObject *callback)
495498
{
496499
if (!_PyType_SUPPORTS_WEAKREFS(Py_TYPE(obj))) {
497500
PyErr_Format(PyExc_TypeError,
@@ -507,7 +510,8 @@ get_or_create_weakref(PyTypeObject *type, weakref_alloc_fn allocate, PyObject *o
507510

508511
LOCK_WEAKREFS(obj);
509512
get_basic_refs(*list, &ref, &proxy);
510-
PyWeakReference *basic_ref = try_reuse_basic_ref(ref, proxy, type, callback);
513+
PyWeakReference *basic_ref =
514+
try_reuse_basic_ref(ref, proxy, type, callback);
511515
if (basic_ref != NULL) {
512516
UNLOCK_WEAKREFS(obj);
513517
return basic_ref;
@@ -565,7 +569,8 @@ weakref___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs)
565569
{
566570
PyObject *ob, *callback = NULL;
567571
if (parse_weakref_init_args("__new__", args, kwargs, &ob, &callback)) {
568-
return (PyObject *) get_or_create_weakref(type, allocate_ref_subtype, ob, callback);
572+
return (PyObject *)get_or_create_weakref(type, allocate_ref_subtype,
573+
ob, callback);
569574
}
570575
return NULL;
571576
}
@@ -1019,7 +1024,8 @@ allocate_ref(PyTypeObject *type, PyObject *obj, PyObject *callback)
10191024
PyObject *
10201025
PyWeakref_NewRef(PyObject *ob, PyObject *callback)
10211026
{
1022-
return (PyObject *) get_or_create_weakref(&_PyWeakref_RefType, allocate_ref, ob, callback);
1027+
return (PyObject *)get_or_create_weakref(&_PyWeakref_RefType, allocate_ref,
1028+
ob, callback);
10231029
}
10241030

10251031
static PyWeakReference *
@@ -1041,7 +1047,8 @@ allocate_proxy(PyTypeObject *type, PyObject *obj, PyObject *callback)
10411047
PyObject *
10421048
PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
10431049
{
1044-
return (PyObject *) get_or_create_weakref(&_PyWeakref_ProxyType, allocate_proxy, ob, callback);
1050+
return (PyObject *)get_or_create_weakref(&_PyWeakref_ProxyType,
1051+
allocate_proxy, ob, callback);
10451052
}
10461053

10471054

Python/pystate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,8 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime)
501501
_PyMutex_at_fork_reinit(locks[i]);
502502
}
503503
#ifdef Py_GIL_DISABLED
504-
for (PyInterpreterState *interp = runtime->interpreters.head; interp != NULL; interp = interp->next) {
504+
for (PyInterpreterState *interp = runtime->interpreters.head;
505+
interp != NULL; interp = interp->next) {
505506
for (int i = 0; i < NUM_WEAKREF_LIST_LOCKS; i++) {
506507
_PyMutex_at_fork_reinit(&interp->weakref_locks[i]);
507508
}

0 commit comments

Comments
 (0)
0