Backport 1.8 3747

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