Author: Ronan Lamy <ronan.l...@gmail.com> Branch: py3k Changeset: r86453:36d4233f4e5c Date: 2016-08-23 16:46 +0100 http://bitbucket.org/pypy/pypy/changeset/36d4233f4e5c/
Log: hg merge default diff --git a/pypy/module/pypyjit/test_pypy_c/test_ffi.py b/pypy/module/pypyjit/test_pypy_c/test_ffi.py --- a/pypy/module/pypyjit/test_pypy_c/test_ffi.py +++ b/pypy/module/pypyjit/test_pypy_c/test_ffi.py @@ -423,7 +423,7 @@ guard_false(i114, descr=...) --TICK-- i123 = arraylen_gc(p67, descr=<ArrayP .>) - i119 = call_i(ConstClass(_ll_1_raw_malloc_varsize__Signed), 6, descr=<Calli . i EF=5 OS=110>) + i119 = call_i(ConstClass(_ll_1_raw_malloc_varsize_zero__Signed), 6, descr=<Calli . i EF=5 OS=110>) check_memory_error(i119) raw_store(i119, 0, i160, descr=<ArrayS 2>) raw_store(i119, 2, i160, descr=<ArrayS 2>) diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py --- a/pypy/objspace/std/intobject.py +++ b/pypy/objspace/std/intobject.py @@ -1029,4 +1029,5 @@ if x >= HASH_MODULUS: x -= HASH_MODULUS - return intmask(intmask(x) * sign) + h = intmask(intmask(x) * sign) + return h - (h == -1) diff --git a/pypy/objspace/std/longobject.py b/pypy/objspace/std/longobject.py --- a/pypy/objspace/std/longobject.py +++ b/pypy/objspace/std/longobject.py @@ -254,12 +254,12 @@ def _make_generic_descr_binop(opname): if opname not in COMMUTATIVE_OPS: raise Exception("Not supported") - + methname = opname + '_' if opname in ('and', 'or') else opname descr_rname = 'descr_r' + opname op = getattr(rbigint, methname) intop = getattr(rbigint, "int_" + methname) - + @func_renamer('descr_' + opname) def descr_binop(self, space, w_other): if isinstance(w_other, W_IntObject): @@ -279,7 +279,7 @@ return W_LongObject(op(w_other.asbigint(), self.num)) return descr_binop, descr_rbinop - + descr_add, descr_radd = _make_generic_descr_binop('add') descr_sub, descr_rsub = _make_generic_descr_binop_noncommutative('sub') descr_mul, descr_rmul = _make_generic_descr_binop('mul') @@ -321,12 +321,12 @@ except OverflowError: # b too big raise oefmt(space.w_OverflowError, "shift count too large") return W_LongObject(self.num.lshift(shift)) - + def _int_lshift(self, space, w_other): if w_other < 0: raise oefmt(space.w_ValueError, "negative shift count") return W_LongObject(self.num.lshift(w_other)) - + descr_lshift, descr_rlshift = _make_descr_binop(_lshift, _int_lshift) def _rshift(self, space, w_other): @@ -337,7 +337,7 @@ except OverflowError: # b too big # XXX maybe just return 0L instead? raise oefmt(space.w_OverflowError, "shift count too large") return newlong(space, self.num.rshift(shift)) - + def _int_rshift(self, space, w_other): if w_other < 0: raise oefmt(space.w_ValueError, "negative shift count") @@ -352,7 +352,7 @@ raise oefmt(space.w_ZeroDivisionError, "long division or modulo by zero") return newlong(space, z) - + def _floordiv(self, space, w_other): try: z = self.num.floordiv(w_other.asbigint()) @@ -369,7 +369,7 @@ raise oefmt(space.w_ZeroDivisionError, "integer division or modulo by zero") return newlong(space, z) - + def _int_mod(self, space, w_other): try: z = self.num.int_mod(w_other) @@ -404,7 +404,8 @@ while x >= HASH_MODULUS: x -= HASH_MODULUS i -= 1 - return intmask(intmask(x) * v.sign) + h = intmask(intmask(x) * v.sign) + return h - (h == -1) def newlong(space, bigint): diff --git a/pypy/objspace/std/test/test_intobject.py b/pypy/objspace/std/test/test_intobject.py --- a/pypy/objspace/std/test/test_intobject.py +++ b/pypy/objspace/std/test/test_intobject.py @@ -265,7 +265,11 @@ result = f1.int(self.space) assert result == f1 -class AppTestInt: +class AppTestInt(object): + def test_hash(self): + assert hash(-1) == (-1).__hash__() == -2 + assert hash(-2) == (-2).__hash__() == -2 + def test_conjugate(self): assert (1).conjugate() == 1 assert (-1).conjugate() == -1 _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit