Replace hex with "0x%x" % ... to fix a trailing 'L' on 32-bit python2

This test was failing because the hash computes values greater than
0x7fffffff, which 32-bit python2 promotes to long, which `hex` formats
with a trailing 'L'. The code that uses it appears to be ok with a
long value, so it's just the test that needs to handle it.

Fix as suggested here:

https://stackoverflow.com/questions/5917203/python-trailing-l-problem
This commit is contained in:
Dan Gohman
2017-12-01 06:32:38 -08:00
parent cced2c8b0c
commit 27f0b29188

View File

@@ -20,9 +20,9 @@ def simple_hash(s):
Compute a primitive hash of a string. Compute a primitive hash of a string.
Example: Example:
>>> hex(simple_hash("Hello")) >>> "0x%x" % simple_hash("Hello")
'0x2fa70c01' '0x2fa70c01'
>>> hex(simple_hash("world")) >>> "0x%x" % simple_hash("world")
'0x5b0c31d5' '0x5b0c31d5'
""" """
h = 5381 h = 5381