Author: Matti Picus <matti.pi...@gmail.com>
Branch: py3.6
Changeset: r97912:33fe0dcb31b8
Date: 2019-10-31 19:37 +0200
http://bitbucket.org/pypy/pypy/changeset/33fe0dcb31b8/

Log:    merge heads

diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -536,7 +536,7 @@
             return w_function.name + '()'
         if isinstance(w_function, Method):
             return self._guess_function_name_parens(None, 
w_function.w_function)
-        return w_function.getname(self.space) + ' object'
+        return self.space.type(w_function).getname(self.space) + ' object'
 
     def make_arguments(self, nargs, methodcall=False, w_function=None, 
fnname=None):
         fnname_parens = self._guess_function_name_parens(fnname, w_function)
diff --git a/pypy/interpreter/test/apptest_function.py 
b/pypy/interpreter/test/apptest_function.py
--- a/pypy/interpreter/test/apptest_function.py
+++ b/pypy/interpreter/test/apptest_function.py
@@ -542,6 +542,25 @@
     im = MethodType(A(), 3)
     assert list(map(im, [4])) == [7]
 
+
+class CallableBadGetattr:
+    def __getattr__(self, name):
+        # Ensure that __getattr__ doesn't get called
+        raise RuntimeError
+
+    def __call__(self, a, b, c):
+        return a, b, c
+
+def test_custom_callable_errors():
+    fn = CallableBadGetattr()
+    with raises(TypeError) as excinfo:
+        fn(*1)
+    assert excinfo.value.args[0].startswith('CallableBadGetattr object')
+    with raises(TypeError) as excinfo:
+        fn()
+    assert excinfo.value.args[0].startswith('__call__()')
+    assert fn(1, 2, 3) == (1, 2, 3)
+
 def test_invalid_creation():
     def f(): pass
     with raises(TypeError):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to