Author: Ronan Lamy <[email protected]>
Branch: py3.6
Changeset: r97723:a8752c53c0d2
Date: 2019-10-04 18:16 +0100
http://bitbucket.org/pypy/pypy/changeset/a8752c53c0d2/
Log: hg merge default
diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -50,4 +50,6 @@
de061d87e39c7df4e436974096d7982c676a859d release-pypy3.6-v7.1.0
784b254d669919c872a505b807db8462b6140973 release-pypy3.6-v7.1.1
8cdda8b8cdb8ff29d9e620cccd6c5edd2f2a23ec release-pypy2.7-v7.1.1
-
+85dae4fd5c234b482feff834c73e089872194541 release-pypy2.7-v7.2.0rc0
+7ffb92269488f37c707ce66076f50ffd8613f8e2 release-pypy3.6-v7.2.0rc0
+4d6761df14ffd6f38450f183ac1fad32c946c21b release-pypy3.6-v7.2.0rc1
diff --git a/pypy/module/_pypyjson/interp_decoder.py
b/pypy/module/_pypyjson/interp_decoder.py
--- a/pypy/module/_pypyjson/interp_decoder.py
+++ b/pypy/module/_pypyjson/interp_decoder.py
@@ -73,6 +73,9 @@
# hit in the cache
STRING_CACHE_USEFULNESS_FACTOR = 4
+ # don't make arbitrarily huge maps
+ MAX_MAP_SIZE = 100
+
def __init__(self, space, s):
self.space = space
@@ -369,7 +372,7 @@
return w_res
elif ch == ',':
i = self.skip_whitespace(i)
- if currmap.is_state_blocked():
+ if currmap.is_state_blocked() or nextindex > self.MAX_MAP_SIZE:
self.scratch.append(values_w) # can reuse next time
dict_w = self._switch_to_dict(currmap, values_w, nextindex)
return self.decode_object_dict(i, start, dict_w)
diff --git a/pypy/module/_pypyjson/simd.py b/pypy/module/_pypyjson/simd.py
--- a/pypy/module/_pypyjson/simd.py
+++ b/pypy/module/_pypyjson/simd.py
@@ -1,7 +1,7 @@
from rpython.rtyper.lltypesystem import lltype, rffi
from rpython.rlib import objectmodel, unroll
from rpython.rlib.rarithmetic import r_uint, intmask, LONG_BIT
-from rpython.jit.backend.detect_cpu import autodetect
+from rpython.jit.backend.detect_cpu import autodetect, ProcessorAutodetectError
# accelerators for string operations using simd on regular word sizes (*not*
# SSE instructions). this style is sometimes called SWAR (SIMD Within A
@@ -15,8 +15,11 @@
WORD_SIZE = 8
EVERY_BYTE_ONE = 0x0101010101010101
EVERY_BYTE_HIGHEST_BIT = 0x8080808080808080
- if autodetect() == "x86-64":
- USE_SIMD = True
+ try:
+ if autodetect() == "x86-64":
+ USE_SIMD = True
+ except ProcessorAutodetectError:
+ pass
else:
WORD_SIZE = 4
EVERY_BYTE_ONE = 0x01010101
diff --git a/pypy/module/_pypyjson/test/test__pypyjson.py
b/pypy/module/_pypyjson/test/test__pypyjson.py
--- a/pypy/module/_pypyjson/test/test__pypyjson.py
+++ b/pypy/module/_pypyjson/test/test__pypyjson.py
@@ -467,6 +467,14 @@
res = _pypyjson.loads(json)
assert res == [{u'a': 1}, {u'a': 2}]
+ def test_huge_map(self):
+ import _pypyjson
+ import __pypy__
+ s = '{' + ",".join('"%s": %s' % (i, i) for i in range(200)) + '}'
+ res = _pypyjson.loads(s)
+ assert len(res) == 200
+ assert __pypy__.strategy(res) == "UnicodeDictStrategy"
+
def test_tab_in_string_should_fail(self):
import _pypyjson
# http://json.org/JSON_checker/test/fail25.json
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
@@ -80,6 +80,13 @@
# XXX this is wrong with IntMutableCell. Hope it works...
return w_dict.getitem(w_key)
+@cpython_api([PyObject, PyObject], PyObject, result_borrowed=True)
+def _PyDict_GetItemWithError(space, w_dict, w_key):
+ # Like PyDict_GetItem(), but doesn't swallow the error
+ if not isinstance(w_dict, W_DictMultiObject):
+ PyErr_BadInternalCall(space)
+ return w_dict.getitem(w_key)
+
@cpython_api([PyObject, PyObject, PyObject], rffi.INT_real, error=-1)
def PyDict_SetItem(space, w_dict, w_key, w_obj):
if not isinstance(w_dict, W_DictMultiObject):
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
@@ -175,6 +175,26 @@
])
assert module.dict_proxy({'a': 1, 'b': 2}) == 2
+ def test_getitemwitherror(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_GetItemWithError(d, key);
+ if (result == NULL && !PyErr_Occurred())
+ Py_RETURN_NONE;
+ Py_XINCREF(result);
+ return result;
+ """)])
+ d = {'foo': 'bar'}
+ assert module.dict_getitem(d, 'foo') == 'bar'
+ assert module.dict_getitem(d, 'missing') is None
+ with raises(TypeError):
+ module.dict_getitem(d, [])
+
def test_setdefault(self):
module = self.import_extension('foo', [
("setdefault", "METH_VARARGS",
diff --git a/pypy/objspace/std/unicodeobject.py
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -36,6 +36,10 @@
def prev_codepoint_pos_dont_look_inside(utf8, p):
return rutf8.prev_codepoint_pos(utf8, p)
[email protected]
+def codepoint_at_pos_dont_look_inside(utf8, p):
+ return rutf8.codepoint_at_pos(utf8, p)
+
class W_UnicodeObject(W_Root):
import_from_mixin(StringMethods)
@@ -122,7 +126,7 @@
raise oefmt(space.w_TypeError,
"ord() expected a character, but string of length %d "
"found", self._len())
- return space.newint(rutf8.codepoint_at_pos(self._utf8, 0))
+ return space.newint(self.codepoint_at_pos_dont_look_inside(0))
def _empty(self):
return W_UnicodeObject.EMPTY
@@ -548,7 +552,7 @@
if self._length == 0:
return space.w_False
if self._length == 1:
- return space.newbool(func(rutf8.codepoint_at_pos(self._utf8, 0)))
+ return
space.newbool(func(self.codepoint_at_pos_dont_look_inside(0)))
else:
return self._is_generic_loop(space, self._utf8, func_name)
@@ -1127,6 +1131,11 @@
return pos - 1
return prev_codepoint_pos_dont_look_inside(self._utf8, pos)
+ def codepoint_at_pos_dont_look_inside(self, pos):
+ if self.is_ascii():
+ return ord(self._utf8[pos])
+ return codepoint_at_pos_dont_look_inside(self._utf8, pos)
+
@always_inline
def _unwrap_and_search(self, space, w_sub, w_start, w_end, forward=True):
w_sub = self.convert_arg_to_w_unicode(space, w_sub)
diff --git a/rpython/translator/revdb/src-revdb/revdb_include.h
b/rpython/translator/revdb/src-revdb/revdb_include.h
--- a/rpython/translator/revdb/src-revdb/revdb_include.h
+++ b/rpython/translator/revdb/src-revdb/revdb_include.h
@@ -285,6 +285,8 @@
#define OP_GC_RAWREFCOUNT_NEXT_DEAD(r) \
r = rpy_reverse_db_rawrefcount_next_dead()
+#define OP_GC_INCREASE_ROOT_STACK_DEPTH(depth, r) /* nothing */
+
RPY_EXTERN void rpy_reverse_db_flush(void); /* must be called with the lock */
RPY_EXTERN void rpy_reverse_db_fetch(const char *file, int line);
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit