[pypy-commit] pypy default: Fix the tests for #2904

2019-01-13 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r95628:d0187cf2f1b7
Date: 2019-01-13 19:21 +0100
http://bitbucket.org/pypy/pypy/changeset/d0187cf2f1b7/

Log:Fix the tests for #2904

diff --git a/pypy/module/pypyjit/test_pypy_c/test_containers.py 
b/pypy/module/pypyjit/test_pypy_c/test_containers.py
--- a/pypy/module/pypyjit/test_pypy_c/test_containers.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_containers.py
@@ -20,7 +20,7 @@
 assert log.result % 1000 == 0
 loop, = log.loops_by_filename(self.filepath)
 ops = loop.ops_by_id('look')
-assert log.opnames(ops) == []
+assert log.opnames(ops) == ['guard_nonnull_class']
 
 def test_identitydict(self):
 def fn(n):
diff --git a/pypy/module/pypyjit/test_pypy_c/test_instance.py 
b/pypy/module/pypyjit/test_pypy_c/test_instance.py
--- a/pypy/module/pypyjit/test_pypy_c/test_instance.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_instance.py
@@ -254,6 +254,7 @@
 guard_no_exception(descr=...)
 i29 = int_lt(i26, 0)
 guard_true(i29, descr=...)
+guard_nonnull_class(p58, ConstClass(W_IntObject), descr=...)
 ''')
 assert loop.match_by_id('loadattr2', "")   # completely folded away
 
diff --git a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py 
b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py
--- a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py
@@ -243,6 +243,8 @@
 f80 = raw_load_f(i67, i79, descr=)
 i81 = int_add(i71, 1)
 --TICK--
+i92 = int_le(i33, _)
+guard_true(i92, descr=...)
 jump(..., descr=...)
 """)
 
@@ -282,6 +284,8 @@
 f86 = float_add(f74, f85)
 i87 = int_add(i76, 1)
 --TICK--
+i98 = int_le(i36, _)
+guard_true(i98, descr=...)
 jump(..., descr=...)
 """)
 
@@ -389,6 +393,8 @@
 assert log.result == [0.] * N
 loop, = log.loops_by_filename(self.filepath)
 assert loop.match("""
+i4 = int_lt(i91, 0)
+guard_false(i4, descr=...)
 i92 = int_ge(i91, i37)
 guard_false(i92, descr=...)
 i93 = int_add(i91, 1)
diff --git a/pypy/module/pypyjit/test_pypy_c/test_misc.py 
b/pypy/module/pypyjit/test_pypy_c/test_misc.py
--- a/pypy/module/pypyjit/test_pypy_c/test_misc.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_misc.py
@@ -113,6 +113,7 @@
 i12 = int_is_true(i4)
 guard_true(i12, descr=...)
 guard_not_invalidated(descr=...)
+guard_nonnull_class(p10, ConstClass(W_IntObject), descr=...)
 i10p = getfield_gc_i(p10, descr=...)
 i10 = int_mul_ovf(2, i10p)
 guard_no_overflow(descr=...)
@@ -148,6 +149,8 @@
 setfield_gc(p9, i17, descr=<.* .*W_XRangeIterator.inst_current .*>)
 guard_not_invalidated(descr=...)
 i18 = force_token()
+i83 = int_lt(0, i14)
+guard_true(i83, descr=...)
 i84 = int_sub(i14, 1)
 i21 = int_lt(i10, 0)
 guard_false(i21, descr=...)
@@ -175,12 +178,16 @@
 loop, = log.loops_by_filename(self.filepath)
 assert loop.match("""
 guard_not_invalidated?
+i80 = int_lt(i11, 0)
+guard_false(i80, descr=...)
 i16 = int_ge(i11, i12)
 guard_false(i16, descr=...)
 i20 = int_add(i11, 1)
 setfield_gc(p4, i20, descr=<.* 
.*W_AbstractSeqIterObject.inst_index .*>)
 guard_not_invalidated?
 i21 = force_token()
+i89 = int_lt(0, i9)
+guard_true(i89, descr=...)
 i88 = int_sub(i9, 1)
 i25 = int_ge(i11, i9)
 guard_false(i25, descr=...)
@@ -214,6 +221,8 @@
 setfield_gc(p4, i20, descr=<.* 
.*W_AbstractSeqIterObject.inst_index .*>)
 guard_not_invalidated?
 i21 = force_token()
+i94 = int_lt(0, i9)
+guard_true(i94, descr=...)
 i95 = int_sub(i9, 1)
 i23 = int_lt(i18, 0)
 guard_false(i23, descr=...)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy unicode-utf8-py3: merge heads

2019-01-13 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: unicode-utf8-py3
Changeset: r95627:59c5294dfb36
Date: 2019-01-13 15:08 +0100
http://bitbucket.org/pypy/pypy/changeset/59c5294dfb36/

Log:merge heads

diff --git a/pypy/objspace/std/dictmultiobject.py 
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -122,17 +122,11 @@
 if w_fill is None:
 w_fill = space.w_None
 if space.is_w(w_type, space.w_dict):
-ulist = space.listview_utf8(w_keys)
-if ulist is not None:
-strategy = space.fromcache(UnicodeDictStrategy)
-storage = strategy.get_storage_fromkeys(ulist, w_fill)
-w_dict = space.allocate_instance(W_DictObject, w_type)
-W_DictObject.__init__(w_dict, space, strategy, storage)
-else:
-w_dict = W_DictMultiObject.allocate_and_init_instance(space,
-  w_type)
-for w_key in space.listview(w_keys):
-w_dict.setitem(w_key, w_fill)
+# XXX consider re-enabling a fast-path here
+w_dict = W_DictMultiObject.allocate_and_init_instance(space,
+  w_type)
+for w_key in space.listview(w_keys):
+w_dict.setitem(w_key, w_fill)
 else:
 w_dict = space.call_function(w_type)
 for w_key in space.listview(w_keys):
@@ -1217,14 +1211,6 @@
 i += 1
 return keys, values
 
-def get_storage_fromkeys(self, keys_w, w_fill):
-"""Return an initialized storage with keys and fill values"""
-storage = {}
-mark_dict_non_null(storage)
-for key in keys_w:
-storage[key] = w_fill
-return self.erase(storage)
-
 create_iterator_classes(UnicodeDictStrategy)
 
 
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py 
b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -125,6 +125,7 @@
 assert self.space.eq_w(space.call_function(get, w("33"), w(44)), w(44))
 
 def test_fromkeys_fastpath(self):
+py.test.skip("doesn't make sense here")
 space = self.space
 w = space.wrap
 
@@ -1190,7 +1191,6 @@
 assert d[""] == 2
 
 def test_empty_to_int(self):
-skip('IntDictStrategy is disabled for now, re-enable it!')
 import sys
 d = {}
 d[1] = "hi"
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy unicode-utf8-py3: disable the fromkeys fast path, it's yet another way to get a non-ascii key

2019-01-13 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: unicode-utf8-py3
Changeset: r95625:0e7fd7135bc7
Date: 2019-01-12 23:16 +0100
http://bitbucket.org/pypy/pypy/changeset/0e7fd7135bc7/

Log:disable the fromkeys fast path, it's yet another way to get a non-
ascii key

diff --git a/pypy/objspace/std/dictmultiobject.py 
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -122,17 +122,11 @@
 if w_fill is None:
 w_fill = space.w_None
 if space.is_w(w_type, space.w_dict):
-ulist = space.listview_utf8(w_keys)
-if ulist is not None:
-strategy = space.fromcache(UnicodeDictStrategy)
-storage = strategy.get_storage_fromkeys(ulist, w_fill)
-w_dict = space.allocate_instance(W_DictObject, w_type)
-W_DictObject.__init__(w_dict, space, strategy, storage)
-else:
-w_dict = W_DictMultiObject.allocate_and_init_instance(space,
-  w_type)
-for w_key in space.listview(w_keys):
-w_dict.setitem(w_key, w_fill)
+# XXX consider re-enabling a fast-path here
+w_dict = W_DictMultiObject.allocate_and_init_instance(space,
+  w_type)
+for w_key in space.listview(w_keys):
+w_dict.setitem(w_key, w_fill)
 else:
 w_dict = space.call_function(w_type)
 for w_key in space.listview(w_keys):
@@ -1217,14 +1211,6 @@
 i += 1
 return keys, values
 
-def get_storage_fromkeys(self, keys_w, w_fill):
-"""Return an initialized storage with keys and fill values"""
-storage = {}
-mark_dict_non_null(storage)
-for key in keys_w:
-storage[key] = w_fill
-return self.erase(storage)
-
 create_iterator_classes(UnicodeDictStrategy)
 
 
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py 
b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -125,6 +125,7 @@
 assert self.space.eq_w(space.call_function(get, w("33"), w(44)), w(44))
 
 def test_fromkeys_fastpath(self):
+py.test.skip("doesn't make sense here")
 space = self.space
 w = space.wrap
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy unicode-utf8-py3: merge py3.5

2019-01-13 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: unicode-utf8-py3
Changeset: r95624:b3a828a76f63
Date: 2019-01-12 22:30 +0100
http://bitbucket.org/pypy/pypy/changeset/b3a828a76f63/

Log:merge py3.5

diff --git a/pypy/objspace/std/test/test_dictmultiobject.py 
b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -1190,7 +1190,6 @@
 assert d[""] == 2
 
 def test_empty_to_int(self):
-skip('IntDictStrategy is disabled for now, re-enable it!')
 import sys
 d = {}
 d[1] = "hi"
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy unicode-utf8-py3: fix the kwargsdict problem

2019-01-13 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: unicode-utf8-py3
Changeset: r95626:e75259de9a45
Date: 2019-01-13 15:08 +0100
http://bitbucket.org/pypy/pypy/changeset/e75259de9a45/

Log:fix the kwargsdict problem

diff --git a/pypy/objspace/std/kwargsdict.py b/pypy/objspace/std/kwargsdict.py
--- a/pypy/objspace/std/kwargsdict.py
+++ b/pypy/objspace/std/kwargsdict.py
@@ -3,7 +3,7 @@
 Based on two lists containing unwrapped key value pairs.
 """
 
-from rpython.rlib import jit, rerased, objectmodel
+from rpython.rlib import jit, rerased, objectmodel, rutf8
 
 from pypy.objspace.std.dictmultiobject import (
 DictStrategy, EmptyDictStrategy, ObjectDictStrategy, UnicodeDictStrategy,
@@ -149,11 +149,12 @@
 strategy = self.space.fromcache(UnicodeDictStrategy)
 keys, values_w = self.unerase(w_dict.dstorage)
 storage = strategy.get_empty_storage()
-d_new = strategy.unerase(storage)
-for i in range(len(keys)):
-d_new[strategy.decodekey_str(keys[i])] = values_w[i]
 w_dict.set_strategy(strategy)
 w_dict.dstorage = storage
+for i in range(len(keys)):
+# NB: this can turn the dict into an object strategy, if a key is
+# not ASCII!
+w_dict.setitem_str(keys[i], values_w[i])
 
 def view_as_kwargs(self, w_dict):
 keys, values_w = self.unerase(w_dict.dstorage)
diff --git a/pypy/objspace/std/test/test_kwargsdict.py 
b/pypy/objspace/std/test/test_kwargsdict.py
--- a/pypy/objspace/std/test/test_kwargsdict.py
+++ b/pypy/objspace/std/test/test_kwargsdict.py
@@ -76,6 +76,14 @@
 assert d.get_strategy() is not strategy
 assert "UnicodeDictStrategy" == d.get_strategy().__class__.__name__
 
+def test_limit_size_non_ascii():
+storage = strategy.get_empty_storage()
+d = W_DictObject(space, strategy, storage)
+for i in range(100):
+assert d.setitem_str("%s" % i, 4) is None
+assert d.get_strategy() is not strategy
+assert "ObjectDictStrategy" == d.get_strategy().__class__.__name__
+
 def test_keys_doesnt_wrap():
 space = FakeSpace()
 space.newlist = None
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit