Skip to content

Commit 4901ea9

Browse files
authored
bpo-41061: Fix incorrect expressions in hashtable (GH-21028)
Signed-off-by: Christian Heimes <christian@python.org>
1 parent d780fa7 commit 4901ea9

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix incorrect expressions and asserts in hashtable code and tests.

Modules/_testinternalcapi.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ test_hashtable(PyObject *self, PyObject *Py_UNUSED(args))
197197
for (key='a'; key <= 'z'; key++) {
198198
_Py_hashtable_entry_t *entry = _Py_hashtable_get_entry(table, TO_PTR(key));
199199
assert(entry != NULL);
200-
assert(entry->key = TO_PTR(key));
201-
assert(entry->value = TO_PTR(VALUE(key)));
200+
assert(entry->key == TO_PTR(key));
201+
assert(entry->value == TO_PTR(VALUE(key)));
202202
}
203203

204204
// Test _Py_hashtable_get()

Python/hashtable.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ _Py_hashtable_get_entry_generic(_Py_hashtable_t *ht, const void *key)
133133
{
134134
Py_uhash_t key_hash = ht->hash_func(key);
135135
size_t index = key_hash & (ht->nbuckets - 1);
136-
_Py_hashtable_entry_t *entry = entry = TABLE_HEAD(ht, index);
136+
_Py_hashtable_entry_t *entry = TABLE_HEAD(ht, index);
137137
while (1) {
138138
if (entry == NULL) {
139139
return NULL;
@@ -155,7 +155,7 @@ _Py_hashtable_get_entry_ptr(_Py_hashtable_t *ht, const void *key)
155155
{
156156
Py_uhash_t key_hash = _Py_hashtable_hash_ptr(key);
157157
size_t index = key_hash & (ht->nbuckets - 1);
158-
_Py_hashtable_entry_t *entry = entry = TABLE_HEAD(ht, index);
158+
_Py_hashtable_entry_t *entry = TABLE_HEAD(ht, index);
159159
while (1) {
160160
if (entry == NULL) {
161161
return NULL;

0 commit comments

Comments
 (0)