Skip to content

Commit 8d8fc98

Browse files
committed
Address code review
1 parent 49e8a98 commit 8d8fc98

File tree

1 file changed

+3
-42
lines changed

1 file changed

+3
-42
lines changed

Objects/dictobject.c

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3290,33 +3290,7 @@ _PyDict_FromKeys(PyObject *cls, PyObject *iterable, PyObject *value)
32903290
return NULL;
32913291

32923292

3293-
if (PyDict_CheckExact(d)) {
3294-
if (PyDict_CheckExact(iterable)) {
3295-
PyDictObject *mp = (PyDictObject *)d;
3296-
3297-
Py_BEGIN_CRITICAL_SECTION2(d, iterable);
3298-
d = (PyObject *)dict_dict_fromkeys(mp, iterable, value);
3299-
Py_END_CRITICAL_SECTION2();
3300-
return d;
3301-
}
3302-
else if (PyFrozenDict_CheckExact(iterable)) {
3303-
PyDictObject *mp = (PyDictObject *)d;
3304-
3305-
Py_BEGIN_CRITICAL_SECTION(d);
3306-
d = (PyObject *)dict_dict_fromkeys(mp, iterable, value);
3307-
Py_END_CRITICAL_SECTION();
3308-
return d;
3309-
}
3310-
else if (PyAnySet_CheckExact(iterable)) {
3311-
PyDictObject *mp = (PyDictObject *)d;
3312-
3313-
Py_BEGIN_CRITICAL_SECTION2(d, iterable);
3314-
d = (PyObject *)dict_set_fromkeys(mp, iterable, value);
3315-
Py_END_CRITICAL_SECTION2();
3316-
return d;
3317-
}
3318-
}
3319-
else if (PyFrozenDict_CheckExact(d)) {
3293+
if (PyAnyDict_CheckExact(d)) {
33203294
if (PyDict_CheckExact(iterable)) {
33213295
PyDictObject *mp = (PyDictObject *)d;
33223296

@@ -3333,7 +3307,7 @@ _PyDict_FromKeys(PyObject *cls, PyObject *iterable, PyObject *value)
33333307
else if (PyAnySet_CheckExact(iterable)) {
33343308
PyDictObject *mp = (PyDictObject *)d;
33353309

3336-
Py_BEGIN_CRITICAL_SECTION(iterable);
3310+
Py_BEGIN_CRITICAL_SECTION(d);
33373311
d = (PyObject *)dict_set_fromkeys(mp, iterable, value);
33383312
Py_END_CRITICAL_SECTION();
33393313
return d;
@@ -3346,20 +3320,7 @@ _PyDict_FromKeys(PyObject *cls, PyObject *iterable, PyObject *value)
33463320
return NULL;
33473321
}
33483322

3349-
if (PyDict_CheckExact(d)) {
3350-
Py_BEGIN_CRITICAL_SECTION(d);
3351-
while ((key = PyIter_Next(it)) != NULL) {
3352-
status = setitem_lock_held((PyDictObject *)d, key, value);
3353-
Py_DECREF(key);
3354-
if (status < 0) {
3355-
assert(PyErr_Occurred());
3356-
goto dict_iter_exit;
3357-
}
3358-
}
3359-
dict_iter_exit:;
3360-
Py_END_CRITICAL_SECTION();
3361-
}
3362-
else if (PyFrozenDict_CheckExact(d)) {
3323+
if (PyAnyDict_CheckExact(d)) {
33633324
while ((key = PyIter_Next(it)) != NULL) {
33643325
status = anydict_setitem_take2((PyDictObject *)d,
33653326
key, Py_NewRef(value));

0 commit comments

Comments
 (0)