Author: Matti Picus <[email protected]>
Branch: py3.6
Changeset: r97784:108d3c00537f
Date: 2019-10-16 08:22 +0300
http://bitbucket.org/pypy/pypy/changeset/108d3c00537f/
Log: merge default into branch
diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -55,3 +55,5 @@
4d6761df14ffd6f38450f183ac1fad32c946c21b release-pypy3.6-v7.2.0rc1
5da45ced70e515f94686be0df47c59abd1348ebc release-pypy3.6-v7.2.0rc2
4a68d8d3d2fc1faec2e83bcb4d28559099092574 release-pypy2.7-v7.2.0rc2
+4a68d8d3d2fc1faec2e83bcb4d28559099092574 release-pypy2.7-v7.2.0
+5da45ced70e515f94686be0df47c59abd1348ebc release-pypy3.6-v7.2.0
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -3,11 +3,9 @@
==========================
.. this is a revision shortly after release-pypy-7.2.0
-.. startrev: 78cd4acbcbec
+.. startrev: a511d86377d6
+.. branch: fix-descrmismatch-crash
-.. branch: json-decoder-maps
+Fix segfault when calling descr-methods with no arguments
-Much faster and more memory-efficient JSON decoding. The resulting
-dictionaries that come out of the JSON decoder have faster lookups too.
-
diff --git a/pypy/doc/whatsnew-pypy2-7.2.0.rst
b/pypy/doc/whatsnew-pypy2-7.2.0.rst
--- a/pypy/doc/whatsnew-pypy2-7.2.0.rst
+++ b/pypy/doc/whatsnew-pypy2-7.2.0.rst
@@ -17,10 +17,6 @@
Add ``DateTime_FromTimestamp`` and ``Date_FromTimestamp``
-.. branch: issue2968
-
-Fix segfault in cpyext_tp_new_tupl
-
.. branch: semlock-deadlock
Test and reduce the probability of a deadlock when acquiring a semaphore by
@@ -79,6 +75,8 @@
Update _ssl on macos to statically link to openssl-1.1.1c
-.. branch: more-cpyext
+.. branch: json-decoder-maps
-Add more datetime C functions and definitions
+Much faster and more memory-efficient JSON decoding. The resulting
+dictionaries that come out of the JSON decoder have faster lookups too.
+
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -394,6 +394,8 @@
@specialize.memo()
def wrappable_class_name(Class):
+ if 'exact_class_applevel_name' in Class.__dict__:
+ return Class.exact_class_applevel_name
try:
return Class.typedef.name
except AttributeError:
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -755,6 +755,7 @@
self.func__args__ = func
elif unwrap_spec == [self_type, ObjSpace, Arguments]:
self.__class__ = BuiltinCodePassThroughArguments1
+ self.descr_reqcls = self_type
miniglobals = {'func': func, 'self_type': self_type}
d = {}
source = """if 1:
@@ -800,10 +801,7 @@
except DescrMismatch:
if w_obj is not None:
args = args.prepend(w_obj)
- return scope_w[0].descr_call_mismatch(space,
- self.descrmismatch_op,
- self.descr_reqcls,
- args)
+ return self._type_unwrap_mismatch(space, args)
except Exception as e:
self.handle_exception(space, e)
w_result = None
@@ -811,6 +809,15 @@
w_result = space.w_None
return w_result
+ def _type_unwrap_mismatch(self, space, args):
+ w_obj = args.firstarg()
+ if w_obj is None:
+ raise oefmt(space.w_SystemError, "unexpected DescrMismatch error")
+ return w_obj.descr_call_mismatch(space,
+ self.descrmismatch_op,
+ self.descr_reqcls,
+ args)
+
def handle_exception(self, space, e):
try:
if not we_are_translated():
@@ -833,10 +840,7 @@
try:
w_result = self.func__args__(space, args)
except DescrMismatch:
- return args.firstarg().descr_call_mismatch(space,
- self.descrmismatch_op,
- self.descr_reqcls,
- args)
+ return self._type_unwrap_mismatch(space, args)
except Exception as e:
self.handle_exception(space, e)
w_result = None
@@ -854,10 +858,7 @@
try:
w_result = self.func__args__(space, w_obj, args)
except DescrMismatch:
- return args.firstarg().descr_call_mismatch(space,
- self.descrmismatch_op,
- self.descr_reqcls,
- args.prepend(w_obj))
+ return self._type_unwrap_mismatch(space, args.prepend(w_obj))
except Exception as e:
self.handle_exception(space, e)
w_result = None
@@ -897,9 +898,7 @@
try:
w_result = self.fastfunc_1(space, w1)
except DescrMismatch:
- return w1.descr_call_mismatch(space,
- self.descrmismatch_op,
- self.descr_reqcls,
+ return self._type_unwrap_mismatch(space,
Arguments(space, [w1]))
except Exception as e:
self.handle_exception(space, e)
@@ -923,9 +922,7 @@
try:
w_result = self.fastfunc_2(space, w1, w2)
except DescrMismatch:
- return w1.descr_call_mismatch(space,
- self.descrmismatch_op,
- self.descr_reqcls,
+ return self._type_unwrap_mismatch(space,
Arguments(space, [w1, w2]))
except Exception as e:
self.handle_exception(space, e)
@@ -950,9 +947,7 @@
try:
w_result = self.fastfunc_3(space, w1, w2, w3)
except DescrMismatch:
- return w1.descr_call_mismatch(space,
- self.descrmismatch_op,
- self.descr_reqcls,
+ return self._type_unwrap_mismatch(space,
Arguments(space, [w1, w2, w3]))
except Exception as e:
self.handle_exception(space, e)
@@ -978,9 +973,7 @@
try:
w_result = self.fastfunc_4(space, w1, w2, w3, w4)
except DescrMismatch:
- return w1.descr_call_mismatch(space,
- self.descrmismatch_op,
- self.descr_reqcls,
+ return self._type_unwrap_mismatch(space,
Arguments(space,
[w1, w2, w3, w4]))
except Exception as e:
diff --git a/pypy/interpreter/test/test_gateway.py
b/pypy/interpreter/test/test_gateway.py
--- a/pypy/interpreter/test/test_gateway.py
+++ b/pypy/interpreter/test/test_gateway.py
@@ -1095,6 +1095,29 @@
# white-box check for opt
assert called[0] is args
+ def test_base_regular_descr_mismatch(self):
+ space = self.space
+
+ def f():
+ raise gateway.DescrMismatch
+
+ w_f = space.wrap(gateway.interp2app_temp(f,
+ unwrap_spec=[]))
+ args = argument.Arguments(space, [])
+ space.raises_w(space.w_SystemError, space.call_args, w_f, args)
+
+ def test_pass_trough_arguments0_descr_mismatch(self):
+ space = self.space
+
+ def f(space, __args__):
+ raise gateway.DescrMismatch
+
+ w_f = space.wrap(gateway.interp2app_temp(f,
+ unwrap_spec=[gateway.ObjSpace,
+ gateway.Arguments]))
+ args = argument.Arguments(space, [])
+ space.raises_w(space.w_SystemError, space.call_args, w_f, args)
+
class AppTestKeywordsToBuiltinSanity(object):
def test_type(self):
@@ -1134,3 +1157,26 @@
d.update(**{clash: 33})
dict.update(d, **{clash: 33})
+
+
+
+class AppTestFastPathCrash(object):
+ def setup_class(cls):
+ cls.w_runappdirect = cls.space.wrap(cls.runappdirect)
+
+ def test_fast_path_crash(self):
+ # issue bb-3091 crash in BuiltinCodePassThroughArguments0.funcrun
+ for obj in (dict, set):
+ with raises(TypeError) as excinfo:
+ if self.runappdirect:
+ import platform
+ if platform.python_implementation() == 'PyPy':
+ msg_fmt = "%s instance as first argument (got %s"
+ else:
+ msg_fmt = "'%s' object but received a '%s'"
+ obj.__init__(0)
+ else:
+ msg_fmt = "'%s' object expected, got '%s'"
+ obj.__init__.im_func(0)
+ msg = msg_fmt %(obj.__name__, 'int')
+ assert msg in str(excinfo.value)
diff --git a/pypy/module/_weakref/interp__weakref.py
b/pypy/module/_weakref/interp__weakref.py
--- a/pypy/module/_weakref/interp__weakref.py
+++ b/pypy/module/_weakref/interp__weakref.py
@@ -157,6 +157,8 @@
class W_WeakrefBase(W_Root):
+ exact_class_applevel_name = 'weakref-or-proxy'
+
def __init__(self, space, w_obj, w_callable):
assert w_callable is not space.w_None # should be really None
self.space = space
diff --git a/pypy/module/_weakref/test/test_weakref.py
b/pypy/module/_weakref/test/test_weakref.py
--- a/pypy/module/_weakref/test/test_weakref.py
+++ b/pypy/module/_weakref/test/test_weakref.py
@@ -545,3 +545,12 @@
p1[42] = p2
assert a1.setkey == 42
assert a1.setvalue is p2
+
+ def test_error_message_wrong_self(self):
+ import _weakref
+ unboundmeth = _weakref.ref.__repr__
+ e = raises(TypeError, unboundmeth, 42)
+ assert "weakref" in str(e.value)
+ if hasattr(unboundmeth, 'im_func'):
+ e = raises(TypeError, unboundmeth.im_func, 42)
+ assert "'weakref-or-proxy'" in str(e.value)
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
@@ -20,6 +20,7 @@
class W_BaseSetObject(W_Root):
typedef = None
+ exact_class_applevel_name = 'set-or-frozenset'
def __init__(self, space, w_iterable=None):
"""Initialize the set by taking ownership of 'setdata'."""
@@ -489,6 +490,12 @@
class W_SetObject(W_BaseSetObject):
+
+ #overridden here so the error is reported correctly
+ def __init__(self, space, w_iterable=None):
+ """Initialize the set by taking ownership of 'setdata'."""
+ W_BaseSetObject.__init__(self, space, w_iterable)
+
def _newobj(self, space, w_iterable):
"""Make a new set by taking ownership of 'w_iterable'."""
return W_SetObject(space, w_iterable)
@@ -504,7 +511,7 @@
Build an unordered collection.""",
__new__ = gateway.interp2app(W_SetObject.descr_new),
- __init__ = gateway.interp2app(W_BaseSetObject.descr_init),
+ __init__ = gateway.interp2app(W_SetObject.descr_init),
__repr__ = gateway.interp2app(W_BaseSetObject.descr_repr),
__hash__ = None,
diff --git a/pypy/objspace/std/test/test_bytesobject.py
b/pypy/objspace/std/test/test_bytesobject.py
--- a/pypy/objspace/std/test/test_bytesobject.py
+++ b/pypy/objspace/std/test/test_bytesobject.py
@@ -1050,3 +1050,10 @@
id_a = id(a)
assert a is not str(a, 'latin1')
assert id_a != id_b
+
+ def test_error_message_wrong_self(self):
+ e = raises(TypeError, bytes.upper, 42)
+ assert "bytes" in str(e.value)
+ if hasattr(bytes.upper, 'im_func'):
+ e = raises(TypeError, bytes.upper.im_func, 42)
+ assert "'bytes'" in str(e.value)
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
@@ -800,6 +800,15 @@
assert 567 .__round__(None) == 567 # fails on CPython
+ def test_error_message_wrong_self(self):
+ unboundmeth = int.__str__
+ e = raises(TypeError, unboundmeth, "!")
+ assert "int" in str(e.value)
+ if hasattr(unboundmeth, 'im_func'):
+ e = raises(TypeError, unboundmeth.im_func, "!")
+ assert "'int'" in str(e.value)
+
+
class AppTestIntShortcut(AppTestInt):
spaceconfig = {"objspace.std.intshortcut": True}
diff --git a/pypy/objspace/std/test/test_longobject.py
b/pypy/objspace/std/test/test_longobject.py
--- a/pypy/objspace/std/test/test_longobject.py
+++ b/pypy/objspace/std/test/test_longobject.py
@@ -511,3 +511,11 @@
assert a is not b
b -= 1
assert a is b
+
+ def test_error_message_wrong_self(self):
+ unboundmeth = long.__str__
+ e = raises(TypeError, unboundmeth, 42)
+ assert "int" in str(e.value)
+ if hasattr(unboundmeth, 'im_func'):
+ e = raises(TypeError, unboundmeth.im_func, 42)
+ assert "'int'" in str(e.value)
diff --git a/pypy/objspace/std/test/test_setobject.py
b/pypy/objspace/std/test/test_setobject.py
--- a/pypy/objspace/std/test/test_setobject.py
+++ b/pypy/objspace/std/test/test_setobject.py
@@ -1118,3 +1118,15 @@
def test_unicode_bug_in_listview_utf8(self):
l1 = set(u'\u1234\u2345')
assert l1 == set([u'\u1234', '\u2345'])
+
+ def test_frozenset_init_does_nothing(self):
+ f = frozenset([1, 2, 3])
+ f.__init__(4, 5, 6)
+ assert f == frozenset([1, 2, 3])
+
+ def test_error_message_wrong_self(self):
+ e = raises(TypeError, frozenset.copy, 42)
+ assert "frozenset" in str(e.value)
+ if hasattr(frozenset.copy, 'im_func'):
+ e = raises(TypeError, frozenset.copy.im_func, 42)
+ assert "'set-or-frozenset'" in str(e.value)
diff --git a/pypy/objspace/std/test/test_tupleobject.py
b/pypy/objspace/std/test/test_tupleobject.py
--- a/pypy/objspace/std/test/test_tupleobject.py
+++ b/pypy/objspace/std/test/test_tupleobject.py
@@ -438,3 +438,12 @@
assert (() != object()) is True
assert ((1,) != object()) is True
assert ((1, 2) != object()) is True
+
+
+ def test_error_message_wrong_self(self):
+ unboundmeth = tuple.__hash__
+ e = raises(TypeError, unboundmeth, 42)
+ assert "tuple" in str(e.value)
+ if hasattr(unboundmeth, 'im_func'):
+ e = raises(TypeError, unboundmeth.im_func, 42)
+ assert "'tuple'" in str(e.value)
\ No newline at end of file
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit