Author: Tyler Wade <way...@gmail.com> Branch: utf8-unicode2 Changeset: r72754:42f8daeaba72 Date: 2014-08-11 03:06 -0500 http://bitbucket.org/pypy/pypy/changeset/42f8daeaba72/
Log: Fix text_index when run on a translated PyPy diff --git a/pypy/interpreter/utf8.py b/pypy/interpreter/utf8.py --- a/pypy/interpreter/utf8.py +++ b/pypy/interpreter/utf8.py @@ -174,9 +174,14 @@ return pos def __getitem__(self, char_pos): - if not isinstance(char_pos, int): - raise TypeError("string index must be an integer, not %r" % - type(char_pos)) + if not we_are_translated(): + if hasattr(char_pos, '__index__'): + char_pos = char_pos.__index__() + + if not isinstance(char_pos, (int, long)): + raise TypeError("string index must be an integer, not %r" % + type(char_pos)) + # This if statement is needed for [-1:0] to slice correctly if char_pos >= self._len: raise IndexError() _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit