Skip to content

Commit d25c9a0

Browse files
committed
Fix formatting
1 parent 9cb367d commit d25c9a0

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

Include/internal/pycore_critical_section.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,18 @@ extern "C" {
114114
// Asserts that the mutex for the given object is locked. The mutex must
115115
// be held by the top-most critical section otherwise there's the
116116
// possibility that the mutex would be swalled out in some code paths.
117-
#define _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op) \
118-
_Py_CRITICAL_SECTION_ASSERT_MUTEX_LOCKED(&_PyObject_CAST(op)->ob_mutex)
117+
#ifdef Py_DEBUG
118+
119+
#define _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op) \
120+
if (Py_REFCNT(op) != 1) { \
121+
_Py_CRITICAL_SECTION_ASSERT_MUTEX_LOCKED(&_PyObject_CAST(op)->ob_mutex); \
122+
}
119123

124+
#else /* Py_DEBUG */
120125

126+
#define _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op)
127+
128+
#endif /* Py_DEBUG */
121129

122130
#else /* !Py_GIL_DISABLED */
123131
// The critical section APIs are no-ops with the GIL.
@@ -263,7 +271,8 @@ _PyCriticalSection_AssertHeld(PyMutex *mutex) {
263271
if (prev & _Py_CRITICAL_SECTION_TWO_MUTEXES) {
264272
_PyCriticalSection2 *cs = (_PyCriticalSection2 *)(prev & ~_Py_CRITICAL_SECTION_MASK);
265273
assert(cs != NULL && (cs->base.mutex == mutex || cs->mutex2 == mutex));
266-
} else {
274+
}
275+
else {
267276
_PyCriticalSection *cs = (_PyCriticalSection *)(tstate->critical_section & ~_Py_CRITICAL_SECTION_MASK);
268277
assert(cs != NULL && cs->mutex == mutex);
269278
}

Objects/dictobject.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ it's USABLE_FRACTION (currently two-thirds) full.
147147
static inline void
148148
ASSERT_DICT_LOCKED(PyObject *op)
149149
{
150-
if (Py_REFCNT(op) != 1) {
151-
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op);
152-
}
150+
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op);
153151
}
154152
#define ASSERT_DICT_LOCKED(op) ASSERT_DICT_LOCKED(_Py_CAST(PyObject*, op))
155153

@@ -1988,7 +1986,8 @@ _PyDict_SetItem_KnownHash(PyObject *op, PyObject *key, PyObject *value,
19881986

19891987
if (mp->ma_keys == Py_EMPTY_KEYS) {
19901988
res = insert_to_emptydict(interp, mp, Py_NewRef(key), hash, Py_NewRef(value));
1991-
} else {
1989+
}
1990+
else {
19921991
/* insertdict() handles any resizing that might be necessary */
19931992
res = insertdict(interp, mp, Py_NewRef(key), hash, Py_NewRef(value));
19941993
}
@@ -2522,7 +2521,8 @@ _PyDict_FromKeys(PyObject *cls, PyObject *iterable, PyObject *value)
25222521
d = (PyObject *)dict_dict_fromkeys(interp, mp, iterable, value);
25232522
Py_END_CRITICAL_SECTION2();
25242523
return d;
2525-
} else if (PyAnySet_CheckExact(iterable)) {
2524+
}
2525+
else if (PyAnySet_CheckExact(iterable)) {
25262526
PyDictObject *mp = (PyDictObject *)d;
25272527

25282528
Py_BEGIN_CRITICAL_SECTION2(d, iterable);
@@ -2875,7 +2875,6 @@ PyDict_Values(PyObject *dict)
28752875
Py_BEGIN_CRITICAL_SECTION(dict);
28762876
res = values_lock_held(dict);
28772877
Py_END_CRITICAL_SECTION();
2878-
28792878
return res;
28802879
}
28812880

@@ -4135,7 +4134,6 @@ PyDict_Contains(PyObject *op, PyObject *key)
41354134
Py_BEGIN_CRITICAL_SECTION(op);
41364135
res = contains_lock_held((PyDictObject *)op, key);
41374136
Py_END_CRITICAL_SECTION();
4138-
41394137
return res;
41404138
}
41414139

0 commit comments

Comments
 (0)