8000 Fixup recursive locking · python/cpython@88ab576 · GitHub
[go: up one dir, main page]

Skip to content

Commit 88ab576

Browse files
committed
Fixup recursive locking
1 parent 7407ce9 commit 88ab576

File tree

1 file changed

+4
-32
lines changed

1 file changed

+4
-32
lines changed

Objects/dictobject.c

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,10 +1342,8 @@ insert_split_dict(PyInterpreterState *interp, PyDictObject *mp,
13421342
LOCK_KEYS(keys);
13431343
if (keys->dk_usable <= 0) {
13441344
/* Need to resize. */
1345-
dictkeys_incref(keys);
1346-
int ins = insertion_resize(interp, mp, 1);
1347-
dictkeys_decref(interp, keys);
13481345
UNLOCK_KEYS(keys);
1346+
int ins = insertion_resize(interp, mp, 1);
13491347
if (ins < 0) {
13501348
return -1;
13511349
}
@@ -1371,30 +1369,6 @@ insert_split_dict(PyInterpreterState *interp, PyDictObject *mp,
13711369
return 0;
13721370
}
13731371

1374-
static int
1375-
convert_to_nonunicode_keys(PyInterpreterState *interp, PyDictObject *mp)
1376-
{
1377-
PyDictKeysObject *keys = mp->ma_keys;
1378-
if (_PyDict_HasSplitTable(mp)) {
1379-
LOCK_KEYS(keys);
1380-
dictkeys_incref(keys);
1381-
} else {
1382-
keys = NULL;
1383-
}
1384-
1385-
int res = insertion_resize(interp, mp, 0);
1386-
1387-
if (keys != NULL) {
1388-
dictkeys_decref(interp, keys);
1389-
UNLOCK_KEYS(keys);
1390-
}
1391-
if (res < 0) {
1392-
return res;
1393-
}
1394-
assert(mp->ma_keys->dk_kind == DICT_KEYS_GENERAL);
1395-
return 0;
1396-
}
1397-
13981372
/*
13991373
Internal routine to insert a new item into the table.
14001374
Used both by the internal resize routine and by the public insert routine.
@@ -1410,9 +1384,9 @@ insertdict(PyInterpreterState *interp, PyDictObject *mp,
14101384
ASSERT_DICT_LOCKED(mp);
14111385

14121386
if (DK_IS_UNICODE(mp->ma_keys) && !PyUnicode_CheckExact(key)) {
1413-
if (convert_to_nonunicode_keys(interp, mp) < 0) {
1387+
if (insertion_resize(interp, mp, 0) < 0)
14141388
goto Fail;
1415-
}
1389+
assert(mp->ma_keys->dk_kind == DICT_KEYS_GENERAL);
14161390
}
14171391

14181392
Py_ssize_t ix = _Py_dict_lookup(mp, key, hash, &old_value);
@@ -3803,7 +3777,7 @@ dict_setdefault_ref_lock_held(PyObject *d, PyObject *key, PyObject *default_valu
38033777
}
38043778

38053779
if (!PyUnicode_CheckExact(key) && DK_IS_UNICODE(mp->ma_keys)) {
3806-
if (convert_to_nonunicode_keys(interp, mp) < 0) {
3780+
if (insertion_resize(interp, mp, 0) < 0) {
38073781
if (result) {
38083782
*result = NULL;
38093783
}
@@ -3997,8 +3971,6 @@ dict_popitem_impl(PyDictObject *self)
39973971
}
39983972
/* Convert split table to combined table */
39993973
if (_PyDict_HasSplitTable(self)) {
4000-
PyDictKeysObject *keys = self->ma_keys;
4001-
40023974
if (dictresize(interp, self, DK_LOG_SIZE(self->ma_keys), 1) < 0) {
40033975
Py_DECREF(res);
40043976
return NULL;

0 commit comments

Comments
 (0)
0