[pypy-commit] pypy default: fix hashing of complex object

fijal noreply at buildbot.pypy.org
Sun Mar 18 08:09:07 CET 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r53775:3e15df923f1b
Date: 2012-03-18 09:08 +0200
http://bitbucket.org/pypy/pypy/changeset/3e15df923f1b/

Log:	fix hashing of complex object

diff --git a/pypy/objspace/std/complexobject.py b/pypy/objspace/std/complexobject.py
--- a/pypy/objspace/std/complexobject.py
+++ b/pypy/objspace/std/complexobject.py
@@ -9,6 +9,7 @@
 from pypy.rlib.rfloat import (
     formatd, DTSF_STR_PRECISION, isinf, isnan, copysign)
 from pypy.rlib import jit
+from pypy.rlib.rarithmetic import intmask
 
 import math
 
@@ -173,7 +174,7 @@
 def hash__Complex(space, w_value):
     hashreal = _hash_float(space, w_value.realval)
     hashimg = _hash_float(space, w_value.imagval)
-    combined = hashreal + 1000003 * hashimg
+    combined = intmask(hashreal + 1000003 * hashimg)
     return space.newint(combined)
 
 def add__Complex_Complex(space, w_complex1, w_complex2):


More information about the pypy-commit mailing list