Backport 1.7 3747

Backport #3747 `BUG: use correct type for hash values`.