]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41061: Fix incorrect expressions in hashtable (GH-21028)
authorChristian Heimes <christian@python.org>
Mon, 22 Jun 2020 07:41:48 +0000 (09:41 +0200)
committerGitHub <noreply@github.com>
Mon, 22 Jun 2020 07:41:48 +0000 (00:41 -0700)
Signed-off-by: Christian Heimes <christian@python.org>
Misc/NEWS.d/next/Core and Builtins/2020-06-21-10-54-02.bpo-41061.AHf9MU.rst [new file with mode: 0644]
Modules/_testinternalcapi.c
Python/hashtable.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-06-21-10-54-02.bpo-41061.AHf9MU.rst b/Misc/NEWS.d/next/Core and Builtins/2020-06-21-10-54-02.bpo-41061.AHf9MU.rst
new file mode 100644 (file)
index 0000000..b5bb816
--- /dev/null
@@ -0,0 +1 @@
+Fix incorrect expressions and asserts in hashtable code and tests.
index 7970e2f4f443fd340640611e05f08f05df3fd70f..ad74af8363ef45eb1b2b0ff546f0925c8db97be8 100644 (file)
@@ -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()
index b92e8ca08c7e1c34dde7f093e030a5fdffeb59d1..09501de199b0e61fc0be38527443adb872e08fe4 100644 (file)
@@ -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;
@@ -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;