Author: Armin Rigo <ar...@tunes.org> Branch: keys_with_hash Changeset: r79338:e898f825312b Date: 2015-09-01 10:39 +0200 http://bitbucket.org/pypy/pypy/changeset/e898f825312b/
Log: the r_dict case diff --git a/rpython/rlib/objectmodel.py b/rpython/rlib/objectmodel.py --- a/rpython/rlib/objectmodel.py +++ b/rpython/rlib/objectmodel.py @@ -790,7 +790,7 @@ def _expected_hash(d, key): if isinstance(d, r_dict): - xxx + return d.key_hash(key) else: return compute_hash(key) diff --git a/rpython/rlib/test/test_objectmodel.py b/rpython/rlib/test/test_objectmodel.py --- a/rpython/rlib/test/test_objectmodel.py +++ b/rpython/rlib/test/test_objectmodel.py @@ -636,6 +636,24 @@ res = interpret(f, [27]) assert res == 42 +def test_rdict_with_hash(): + def f(i): + d = r_dict(strange_key_eq, strange_key_hash) + h = strange_key_hash("abc") + assert h == strange_key_hash("aXX") and strange_key_eq("abc", "aXX") + setitem_with_hash(d, "abc", h, i) + assert getitem_with_hash(d, "aXX", h) == i + try: + getitem_with_hash(d, "bYY", strange_key_hash("bYY")) + except KeyError: + pass + else: + raise AssertionError + return 0 + + assert f(29) == 0 + interpret(f, [27]) + def test_import_from_mixin(): class M: # old-style def f(self): pass _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit