[pypy-commit] pypy py3.5: test and fix

arigo pypy.commits at gmail.com
Tue Nov 1 06:00:46 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r88017:63c487334766
Date: 2016-11-01 11:00 +0100
http://bitbucket.org/pypy/pypy/changeset/63c487334766/

Log:	test and fix

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
@@ -92,6 +92,8 @@
 
 class methodcaller(object):
     def __init__(self, method_name, *args, **kwargs):
+        if not isinstance(method_name, str):
+            raise TypeError("method name must be a string")
         self._method_name = method_name
         self._args = args
         self._kwargs = kwargs
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,11 @@
         assert methodcaller("method", 4, 5)(x) == (4, 5)
         assert methodcaller("method", 4, arg2=42)(x) == (4, 42)
 
+    def test_methodcaller_not_string(self):
+        import _operator as operator
+        e = raises(TypeError, operator.methodcaller, 42)
+        assert str(e.value) == "method name must be a string"
+
     def test_index(self):
         import _operator as operator
         assert operator.index(42) == 42


More information about the pypy-commit mailing list