Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r88494:c43509390348
Date: 2016-11-20 16:49 +0100
http://bitbucket.org/pypy/pypy/changeset/c43509390348/
Log: hg merge default
diff --git a/pypy/module/operator/app_operator.py
b/pypy/module/operator/app_operator.py
--- a/pypy/module/operator/app_operator.py
+++ b/pypy/module/operator/app_operator.py
@@ -91,11 +91,14 @@
class methodcaller(object):
- def __init__(self, method_name, *args, **kwargs):
+ def __init__(*args, **kwargs):
+ if len(args) < 2:
+ raise TypeError("methodcaller() called with not enough arguments")
+ self, method_name = args[:2]
if not isinstance(method_name, str):
raise TypeError("method name must be a string")
self._method_name = method_name
- self._args = args
+ self._args = args[2:]
self._kwargs = kwargs
def __call__(self, obj):
diff --git a/pypy/module/operator/test/test_operator.py
b/pypy/module/operator/test/test_operator.py
--- a/pypy/module/operator/test/test_operator.py
+++ b/pypy/module/operator/test/test_operator.py
@@ -182,6 +182,13 @@
assert methodcaller("method", 4, 5)(x) == (4, 5)
assert methodcaller("method", 4, arg2=42)(x) == (4, 42)
+ def test_methodcaller_self(self):
+ from operator import methodcaller
+ class X:
+ def method(myself, self):
+ return self * 6
+ assert methodcaller("method", self=7)(X()) == 42
+
def test_methodcaller_not_string(self):
import _operator as operator
e = raises(TypeError, operator.methodcaller, 42)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit