Skip to content

Commit c326efa

Browse files
committed
Fix formatting
1 parent 44afe35 commit c326efa

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
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 & 9 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

@@ -1987,7 +1985,8 @@ _PyDict_SetItem_KnownHash(PyObject *op, PyObject *key, PyObject *value,
19871985

19881986
if (mp->ma_keys == Py_EMPTY_KEYS) {
19891987
res = insert_to_emptydict(interp, mp, Py_NewRef(key), hash, Py_NewRef(value));
1990-
} else {
1988+
}
1989+
else {
19911990
/* insertdict() handles any resizing that might be necessary */
19921991
res = insertdict(interp, mp, Py_NewRef(key), hash, Py_NewRef(value));
19931992
}
@@ -2521,7 +2520,8 @@ _PyDict_FromKeys(PyObject *cls, PyObject *iterable, PyObject *value)
25212520
d = (PyObject *)dict_dict_fromkeys(interp, mp, iterable, value);
25222521
Py_END_CRITICAL_SECTION2();
25232522
return d;
2524-
} else if (PyAnySet_CheckExact(iterable)) {
2523+
}
2524+
else if (PyAnySet_CheckExact(iterable)) {
25252525
PyDictObject *mp = (PyDictObject *)d;
25262526

25272527
Py_BEGIN_CRITICAL_SECTION2(d, iterable);
@@ -2874,7 +2874,6 @@ PyDict_Values(PyObject *dict)
28742874
Py_BEGIN_CRITICAL_SECTION(dict);
28752875
res = values_lock_held(dict);
28762876
Py_END_CRITICAL_SECTION();
2877-
28782877
return res;
28792878
}
28802879

@@ -3732,11 +3731,9 @@ PyObject *
37323731
PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *defaultobj)
37333732
{
37343733
PyObject *res;
3735-
37363734
Py_BEGIN_CRITICAL_SECTION(d);
37373735
res = setdefault_lock_held(d, key, defaultobj);
37383736
Py_END_CRITICAL_SECTION();
3739-
37403737
return res;
37413738
}
37423739

@@ -4089,7 +4086,6 @@ PyDict_Contains(PyObject *op, PyObject *key)
40894086
Py_BEGIN_CRITICAL_SECTION(op);
40904087
res = contains_lock_held((PyDictObject *)op, key);
40914088
Py_END_CRITICAL_SECTION();
4092-
40934089
return res;
40944090
}
40954091

0 commit comments

Comments
 (0)