Commits

Philip Jenvey  committed 61a7394

simplify

  • Participants
  • Parent commits 21bfa9a

Comments (0)

Files changed (2)

File pypy/module/__builtin__/app_operation.py

+import operator
+
 def bin(x):
-    if isinstance(x, (int, long)):
-        value = x
-    elif hasattr(x, '__index__'):
-        value = x.__index__()
-    else:
-        raise TypeError("object cannot be interpreted as an index")
+    value = operator.index(x)
     return value.__format__("#b")

File pypy/module/__builtin__/test/test_builtin.py

             def __int__(self):
                 return 42
         exc = raises(TypeError, bin, D())
-        assert exc.value.message.find("object cannot be interpreted as an index") != -1
+        assert "index" in exc.value.message
 
     def test_unichr(self):
         import sys