Skip to content

Commit 6866de5

Browse files
author
Marco Sulla
committed
fixed various asserts
1 parent 14fc8af commit 6866de5

File tree

4 files changed

+6
-18
lines changed

4 files changed

+6
-18
lines changed

frozendict/src/3_10/frozendictobject.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -885,8 +885,6 @@ static int frozendict_insert(PyDictObject *mp,
885885
if (empty) {
886886
/* Insert into new slot. */
887887

888-
assert(old_value == NULL);
889-
890888
if (mp->ma_keys->dk_usable <= 0) {
891889
/* Need to resize. */
892890
if (frozendict_resize(mp, GROWTH_RATE(mp))) {
@@ -912,7 +910,6 @@ static int frozendict_insert(PyDictObject *mp,
912910
assert(keys->dk_usable >= 0);
913911
}
914912
else {
915-
assert(old_value != NULL);
916913
DK_ENTRIES(mp->ma_keys)[ix].me_value = value;
917914
Py_DECREF(old_value); /* which **CAN** re-enter (see issue #22653) */
918915
Py_DECREF(key);
@@ -1130,6 +1127,8 @@ frozendict_fromkeys_impl(PyObject *type, PyObject *iterable, PyObject *value)
11301127
}
11311128
}
11321129

1130+
ASSERT_CONSISTENT(mp);
1131+
11331132
if ((PyTypeObject*) type == &PyFrozenDict_Type || (PyTypeObject*) type == &PyCoold_Type) {
11341133
return d;
11351134
}
@@ -2378,8 +2377,6 @@ static PyObject* _frozendict_new(
23782377

23792378
mp->ma_version_tag = DICT_NEXT_VERSION();
23802379

2381-
ASSERT_CONSISTENT(mp);
2382-
23832380
return self;
23842381
}
23852382

frozendict/src/3_6/frozendictobject.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,6 @@ static int frozendict_insert(PyDictObject *mp,
884884
if (empty) {
885885
/* Insert into new slot. */
886886

887-
assert(old_value == NULL);
888-
889887
if (mp->ma_keys->dk_usable <= 0) {
890888
/* Need to resize. */
891889
if (frozendict_resize(mp, GROWTH_RATE(mp))) {
@@ -911,7 +909,6 @@ static int frozendict_insert(PyDictObject *mp,
911909
assert(keys->dk_usable >= 0);
912910
}
913911
else {
914-
assert(old_value != NULL);
915912
DK_ENTRIES(mp->ma_keys)[ix].me_value = value;
916913
Py_DECREF(old_value); /* which **CAN** re-enter (see issue #22653) */
917914
Py_DECREF(key);

frozendict/src/3_7/frozendictobject.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,6 @@ static int frozendict_insert(PyDictObject *mp,
893893
if (empty) {
894894
/* Insert into new slot. */
895895

896-
assert(old_value == NULL);
897-
898896
if (mp->ma_keys->dk_usable <= 0) {
899897
/* Need to resize. */
900898
if (frozendict_resize(mp, GROWTH_RATE(mp))) {
@@ -920,7 +918,6 @@ static int frozendict_insert(PyDictObject *mp,
920918
assert(keys->dk_usable >= 0);
921919
}
922920
else {
923-
assert(old_value != NULL);
924921
DK_ENTRIES(mp->ma_keys)[ix].me_value = value;
925922
Py_DECREF(old_value); /* which **CAN** re-enter (see issue #22653) */
926923
Py_DECREF(key);
@@ -1138,6 +1135,8 @@ frozendict_fromkeys_impl(PyObject *type, PyObject *iterable, PyObject *value)
11381135
}
11391136
}
11401137

1138+
ASSERT_CONSISTENT(mp);
1139+
11411140
if ((PyTypeObject*) type == &PyFrozenDict_Type || (PyTypeObject*) type == &PyCoold_Type) {
11421141
return d;
11431142
}
@@ -2277,8 +2276,6 @@ static PyObject* _frozendict_new(
22772276

22782277
mp->ma_version_tag = DICT_NEXT_VERSION();
22792278

2280-
ASSERT_CONSISTENT(mp);
2281-
22822279
return self;
22832280
}
22842281

frozendict/src/3_8/frozendictobject.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -897,8 +897,6 @@ static int frozendict_insert(PyDictObject *mp,
897897
if (empty) {
898898
/* Insert into new slot. */
899899

900-
assert(old_value == NULL);
901-
902900
if (mp->ma_keys->dk_usable <= 0) {
903901
/* Need to resize. */
904902
if (frozendict_resize(mp, GROWTH_RATE(mp))) {
@@ -924,7 +922,6 @@ static int frozendict_insert(PyDictObject *mp,
924922
assert(keys->dk_usable >= 0);
925923
}
926924
else {
927-
assert(old_value != NULL);
928925
DK_ENTRIES(mp->ma_keys)[ix].me_value = value;
929926
Py_DECREF(old_value); /* which **CAN** re-enter (see issue #22653) */
930927
Py_DECREF(key);
@@ -1142,6 +1139,8 @@ frozendict_fromkeys_impl(PyObject *type, PyObject *iterable, PyObject *value)
11421139
}
11431140
}
11441141

1142+
ASSERT_CONSISTENT(mp);
1143+
11451144
if ((PyTypeObject*) type == &PyFrozenDict_Type || (PyTypeObject*) type == &PyCoold_Type) {
11461145
return d;
11471146
}
@@ -2388,8 +2387,6 @@ static PyObject* _frozendict_new(
23882387

23892388
mp->ma_version_tag = DICT_NEXT_VERSION();
23902389

2391-
ASSERT_CONSISTENT(mp);
2392-
23932390
return self;
23942391
}
23952392

0 commit comments

Comments
 (0)