Author: Ronan Lamy <[email protected]>
Branch: py3.6
Changeset: r97802:2126ee5b7acd
Date: 2019-10-17 18:28 +0100
http://bitbucket.org/pypy/pypy/changeset/2126ee5b7acd/
Log: hg merge default
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -22,9 +22,13 @@
__all__ = ['ObjSpace', 'OperationError', 'W_Root']
+def get_printable_location(tp):
+ return "unpackiterable: %s" % (tp, )
+
unpackiterable_driver = jit.JitDriver(name='unpackiterable',
greens=['tp'],
- reds=['items', 'w_iterator'])
+ reds=['items', 'w_iterator'],
+
get_printable_location=get_printable_location)
class W_Root(object):
diff --git a/pypy/module/cpyext/dictobject.py b/pypy/module/cpyext/dictobject.py
--- a/pypy/module/cpyext/dictobject.py
+++ b/pypy/module/cpyext/dictobject.py
@@ -78,7 +78,10 @@
# *values* as full objects, which stay alive as long as the dict is
# alive and not modified. So we can return a borrowed ref.
# XXX this is wrong with IntMutableCell. Hope it works...
- return w_dict.getitem(w_key)
+ try:
+ return w_dict.getitem(w_key)
+ except OperationError:
+ return None
@cpython_api([PyObject, PyObject], PyObject, result_borrowed=True)
def PyDict_GetItemWithError(space, w_dict, w_key):
diff --git a/pypy/module/cpyext/test/test_dictobject.py
b/pypy/module/cpyext/test/test_dictobject.py
--- a/pypy/module/cpyext/test/test_dictobject.py
+++ b/pypy/module/cpyext/test/test_dictobject.py
@@ -416,3 +416,20 @@
d[1] = 2
assert d[1] == 42
assert module.dict_getitem(d, 1) == 2
+
+ def test_getitem_error(self):
+ module = self.import_extension('foo', [
+ ("dict_getitem", "METH_VARARGS",
+ """
+ PyObject *d, *key, *result;
+ if (!PyArg_ParseTuple(args, "OO", &d, &key)) {
+ return NULL;
+ }
+ result = PyDict_GetItem(d, key);
+ if (!result) Py_RETURN_NONE;
+ Py_XINCREF(result);
+ return result;
+ """),
+ ])
+ assert module.dict_getitem(42, 43) is None
+ assert module.dict_getitem({}, []) is None
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -693,10 +693,12 @@
return unerase_item(erased)
def _mapdict_write_storage(self, storageindex, value):
- for i in rangenmin1:
- if storageindex == i:
- setattr(self, "_value%s" % i, value)
- return
+ assert storageindex >= 0
+ if storageindex < nmin1:
+ for i in rangenmin1:
+ if storageindex == i:
+ setattr(self, "_value%s" % i, value)
+ return
if self._has_storage_list():
self._mapdict_get_storage_list()[storageindex - nmin1] = value
return
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -1658,9 +1658,13 @@
w_set.sstorage = w_set.strategy.get_storage_from_list(iterable_w)
+def get_printable_location(tp, strategy):
+ return "create_set: %s %s" % (tp, strategy)
+
create_set_driver = jit.JitDriver(name='create_set',
greens=['tp', 'strategy'],
- reds='auto')
+ reds='auto',
+
get_printable_location=get_printable_location)
def _create_from_iterable(space, w_set, w_iterable):
w_set.strategy = strategy = space.fromcache(EmptySetStrategy)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit