8000 Fix style issues · python/cpython@0941e62 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0941e62

Browse files
committed
Fix style issues
1 parent cb1f8bd commit 0941e62

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

Objects/dictobject.c

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5029,7 +5029,7 @@ dictiter_iternextkey(PyObject *self)
50295029

50305030
PyObject *value;
50315031
#ifdef Py_GIL_DISABLED
5032-
if (!dictiter_iternext_threadsafe(d, self, &value, NULL)) {
5032+
if (!dictiter_iternext_threadsafe(d, self, &value, NULL) == 0) {
50335033
value = NULL;
50345034
}
50355035
#else
@@ -5152,7 +5152,7 @@ dictiter_iternextvalue(PyObject *self)
51525152

51535153
PyObject *value;
51545154
#ifdef Py_GIL_DISABLED
5155-
if (!dictiter_iternext_threadsafe(d, self, NULL, &value)) {
5155+
if (!dictiter_iternext_threadsafe(d, self, NULL, &value) == 0) {
51565156
value = NULL;
51575157
}
51585158
#else
@@ -5209,7 +5209,7 @@ dictiter_iternextitem_lock_held(PyDictObject *d, PyObject *self,
52095209
PyErr_SetString(PyExc_RuntimeError,
52105210
"dictionary changed size during iteration");
52115211
di->di_used = -1; /* Make this state sticky */
5212-
return 0;
5212+
return -1;
52135213
}
52145214

52155215
i = FT_ATOMIC_LOAD_SSIZE_RELAXED(di->di_pos);
@@ -5262,12 +5262,12 @@ dictiter_iternextitem_lock_held(PyDictObject *d, PyObject *self,
52625262
if (out_value != NULL) {
52635263
*out_value = Py_NewRef(value);
52645264
}
5265-
return 1;
5265+
return 0;
52665266

52675267
fail:
52685268
di->di_dict = NULL;
52695269
Py_DECREF(d);
5270-
return 0;
5270+
return -1;
52715271
}
52725272

52735273
#ifdef Py_GIL_DISABLED
@@ -5319,7 +5319,7 @@ dictiter_iternext_threadsafe(PyDictObject *d, PyObject *self,
53195319
PyErr_SetString(PyExc_RuntimeError,
53205320
"dictionary changed size during iteration");
53215321
di->di_used = -1; /* Make this state sticky */
5322-
return 0;
5322+
return -1;
53235323
}
53245324

53255325
ensure_shared_on_read(d);
@@ -5329,12 +5329,14 @@ dictiter_iternext_threadsafe(PyDictObject *d, PyObject *self,
53295329
assert(i >= 0);
53305330
if (_PyDict_HasSplitTable(d)) {
53315331
PyDictValues *values = _Py_atomic_load_ptr_relaxed(&d->ma_values);
5332-
if (values == NULL)
5332+
if (values == NULL) {
53335333
goto concurrent_modification;
5334+
}
53345335

53355336
Py_ssize_t used = load_values_used_size(values);
5336-
if (i >= used)
5337+
if (i >= used) {
53375338
goto fail;
5339+
}
53385340

53395341
// We're racing against writes to the order from delete_index_from_values, but
53405342
// single threaded can suffer from concurrent modification to those as well and
@@ -5391,7 +5393,7 @@ dictiter_iternext_threadsafe(PyDictObject *d, PyObject *self,
53915393

53925394
_Py_atomic_store_ssize_relaxed(&di->di_pos, i + 1);
53935395
_Py_atomic_store_ssize_relaxed(&di->len, len - 1);
5394-
return 1;
5396+
return 0;
53955397

53965398
concurrent_modification:
53975399
PyErr_SetString(PyExc_RuntimeError,
@@ -5400,14 +5402,14 @@ dictiter_iternext_threadsafe(PyDictObject *d, PyObject 8000 *self,
54005402
fail:
54015403
di->di_dict = NULL;
54025404
Py_DECREF(d);
5403-
return 0;
5405+
return -1;
54045406

5405-
int success;
5407+
int res;
54065408
try_locked:
54075409
Py_BEGIN_CRITICAL_SECTION(d);
5408-
success = dictiter_iternextitem_lock_held(d, self, out_key, out_value);
5410+
res = dictiter_iternextitem_lock_held(d, self, out_key, out_value);
54095411
Py_END_CRITICAL_SECTION();
5410-
return success;
5412+
return res;
54115413
}
54125414

54135415
#endif
@@ -5427,11 +5429,7 @@ has_unique_reference(PyObject *op)
54275429
static bool
54285430
acquire_iter_result(PyObject *result)
54295431
{
5430-
#ifdef Py_GIL_DISABLED
54315432
if (has_unique_reference(result)) {
5432-
#else
5433-
if (Py_REFCNT(result) == 1) {
5434-
#endif
54355433
Py_INCREF(result);
54365434
return true;
54375435
}
@@ -5449,9 +5447,9 @@ dictiter_iternextitem(PyObject *self)
54495447

54505448
PyObject *key, *value;
54515449
#ifdef Py_GIL_DISABLED
5452-
if (dictiter_iternext_threadsafe(d, self, &key, &value)) {
5450+
if (dictiter_iternext_threadsafe(d, self, &key, &value) == 0) {
54535451
#else
5454-
if (dictiter_iternextitem_lock_held(d, self, &key, &value)) {
5452+
if (dictiter_iternextitem_lock_held(d, self, &key, &value) == 0) {
54555453

54565454
#endif
54575455
PyObject *result = di->di_result;

0 commit comments

Comments
 (0)
0