Author: Carl Friedrich Bolz <[email protected]>
Branch: better-error-missing-self
Changeset: r87549:6ef9080035c4
Date: 2016-10-03 19:54 +0200
http://bitbucket.org/pypy/pypy/changeset/6ef9080035c4/
Log: make sure to not produce the error in the module.function(...) case
with the wrong argument number
diff --git a/pypy/interpreter/test/test_argument.py
b/pypy/interpreter/test/test_argument.py
--- a/pypy/interpreter/test/test_argument.py
+++ b/pypy/interpreter/test/test_argument.py
@@ -744,6 +744,11 @@
exc = raises(TypeError, f0, 1)
assert exc.value.message == "f0() takes no arguments (1 given)"
+ def test_error_message_module_function(self):
+ import operator # use repeat because it's defined at applevel
+ exc = raises(TypeError, lambda : operator.repeat(1, 2, 3))
+ assert exc.value.message == "repeat() takes exactly 2 arguments (3
given)"
+
def test_unicode_keywords(self):
def f(**kwargs):
diff --git a/pypy/objspace/std/callmethod.py b/pypy/objspace/std/callmethod.py
--- a/pypy/objspace/std/callmethod.py
+++ b/pypy/objspace/std/callmethod.py
@@ -94,7 +94,7 @@
w_callable = f.peekvalue(n_args + (2 * n_kwargs) + 1)
try:
w_result = f.space.call_valuestack(
- w_callable, n, f, methodcall=True)
+ w_callable, n, f, methodcall=w_self is not None)
finally:
f.dropvalues(n_args + 2)
else:
@@ -112,7 +112,8 @@
arguments = f.popvalues(n) # includes w_self if it is not None
args = f.argument_factory(
- arguments, keywords, keywords_w, None, None, methodcall=True)
+ arguments, keywords, keywords_w, None, None,
+ methodcall=w_self is not None)
if w_self is None:
f.popvalue() # removes w_self, which is None
w_callable = f.popvalue()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit