Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix incorrect expressions and asserts in hashtable code and tests.
4 changes: 2 additions & 2 deletions Modules/_testinternalcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ test_hashtable(PyObject *self, PyObject *Py_UNUSED(args))
for (key='a'; key <= 'z'; key++) {
_Py_hashtable_entry_t *entry = _Py_hashtable_get_entry(table, TO_PTR(key));
assert(entry != NULL);
assert(entry->key = TO_PTR(key));
assert(entry->value = TO_PTR(VALUE(key)));
assert(entry->key == TO_PTR(key));
assert(entry->value == TO_PTR(VALUE(key)));
}

// Test _Py_hashtable_get()
Expand Down
4 changes: 2 additions & 2 deletions Python/hashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ _Py_hashtable_get_entry_generic(_Py_hashtable_t *ht, const void *key)
{
Py_uhash_t key_hash = ht->hash_func(key);
size_t index = key_hash & (ht->nbuckets - 1);
_Py_hashtable_entry_t *entry = entry = TABLE_HEAD(ht, index);
_Py_hashtable_entry_t *entry = TABLE_HEAD(ht, index);
while (1) {
if (entry == NULL) {
return NULL;
Expand All @@ -155,7 +155,7 @@ _Py_hashtable_get_entry_ptr(_Py_hashtable_t *ht, const void *key)
{
Py_uhash_t key_hash = _Py_hashtable_hash_ptr(key);
size_t index = key_hash & (ht->nbuckets - 1);
_Py_hashtable_entry_t *entry = entry = TABLE_HEAD(ht, index);
_Py_hashtable_entry_t *entry = TABLE_HEAD(ht, index);
while (1) {
if (entry == NULL) {
return NULL;
Expand Down