Author: fijal Branch: unicode-utf8 Changeset: r90570:3e38274ddd35 Date: 2017-03-05 19:42 +0400 http://bitbucket.org/pypy/pypy/changeset/3e38274ddd35/
Log: disable speedups for now diff --git a/pypy/module/_pypyjson/interp_decoder.py b/pypy/module/_pypyjson/interp_decoder.py --- a/pypy/module/_pypyjson/interp_decoder.py +++ b/pypy/module/_pypyjson/interp_decoder.py @@ -295,7 +295,7 @@ i += 1 bits |= ord(ch) if ch == '"': - if bits & 0x80: + if 1 or bits & 0x80: # the 8th bit is set, it's an utf8 strnig content_utf8 = self.getslice(start, i-1) content_unicode = unicodehelper.decode_utf8(self.space, content_utf8) diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py --- a/pypy/objspace/std/unicodeobject.py +++ b/pypy/objspace/std/unicodeobject.py @@ -20,6 +20,7 @@ from pypy.objspace.std.formatting import mod_format from pypy.objspace.std.stringmethods import StringMethods from pypy.objspace.std.util import IDTAG_SPECIAL, IDTAG_SHIFT +from pypy.objspace.std.sliceobject import unwrap_start_stop __all__ = ['W_UnicodeObject', 'wrapunicode', 'plain_str2unicode', 'encode_object', 'decode_object', 'unicode_from_object', @@ -75,6 +76,13 @@ uid = (base << IDTAG_SHIFT) | IDTAG_SPECIAL return space.newint(uid) + def _convert_idx_params_unicode(self, space, w_start, w_end): + """ Specialcase this for unicode - one less element in the tuple + """ + lenself = self._len() + start, end = unwrap_start_stop(space, lenself, w_start, w_end) + return start, end + def str_w(self, space): return space.text_w(space.str(self)) @@ -125,8 +133,8 @@ return rutf8.compute_length_utf8(self._utf8) def _val(self, space): - #import pdb - #pdb.set_trace() + import pdb + pdb.set_trace() return self._utf8.decode('utf8') @staticmethod @@ -446,9 +454,6 @@ i = rutf8.next_codepoint_pos(val, i) return space.newbool(cased) - def _starts_ends_overflow(self, prefix): - return len(prefix) == 0 - def descr_add(self, space, w_other): try: w_other = self.convert_arg_to_w_unicode(space, w_other) @@ -722,6 +727,26 @@ assert rpos >= lpos # annotator hint, don't remove return self._utf8_sliced(lpos, rpos, lgt) + def descr_startswith(self, space, w_prefix, w_start=None, w_end=None): + (start, end) = self._convert_idx_params_unicode(space, w_start, w_end) + if space.isinstance_w(w_prefix, space.w_tuple): + return self._startswith_tuple(space, w_prefix, start, end) + return space.newbool(self._startswith(space, w_prefix, start, end)) + + def _startswith_tuple(self, space, w_prefix, start, end): + for w_prefix in space.fixedview(w_prefix): + if self._startswith(space, w_prefix, start, end): + return space.w_True + return space.w_False + + def _startswith(self, space, w_prefix, start, end): + prefix = self.convert_arg_to_w_unicode(space, w_prefix)._utf8 + if start > self._len(): + return len(prefix) == 0 # bug-to-bug cpython compatibility + xxx + return startswith(self._utf8, prefix, start, end) + + def descr_getnewargs(self, space): return space.newtuple([W_UnicodeObject(self._utf8, self._length)]) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit