Author: Carl Friedrich Bolz <cfb...@gmx.de> Branch: space-newtext Changeset: r88110:65ea20add619 Date: 2016-11-03 10:50 +0100 http://bitbucket.org/pypy/pypy/changeset/65ea20add619/
Log: _sre diff --git a/pypy/module/_sre/interp_sre.py b/pypy/module/_sre/interp_sre.py --- a/pypy/module/_sre/interp_sre.py +++ b/pypy/module/_sre/interp_sre.py @@ -19,11 +19,11 @@ @unwrap_spec(char_ord=int, flags=int) def w_getlower(space, char_ord, flags): - return space.wrap(getlower(char_ord, flags)) + return space.newint(getlower(char_ord, flags)) def w_getcodesize(space): - return space.wrap(CODESIZE) + return space.newint(CODESIZE) # use the same version of unicodedb as the standard objspace import pypy.objspace.std.unicodeobject @@ -74,20 +74,20 @@ def import_re(space): w_builtin = space.getbuiltinmodule('__builtin__') - w_import = space.getattr(w_builtin, space.wrap("__import__")) - return space.call_function(w_import, space.wrap("re")) + w_import = space.getattr(w_builtin, space.newtext("__import__")) + return space.call_function(w_import, space.newtext("re")) def matchcontext(space, ctx): try: return rsre_core.match_context(ctx) except rsre_core.Error as e: - raise OperationError(space.w_RuntimeError, space.wrap(e.msg)) + raise OperationError(space.w_RuntimeError, space.newtext(e.msg)) def searchcontext(space, ctx): try: return rsre_core.search_context(ctx) except rsre_core.Error as e: - raise OperationError(space.w_RuntimeError, space.wrap(e.msg)) + raise OperationError(space.w_RuntimeError, space.newtext(e.msg)) # ____________________________________________________________ # @@ -160,7 +160,7 @@ if not searchcontext(space, ctx): break num_groups = self.num_groups - w_emptystr = space.wrap("") + w_emptystr = space.newtext("") if num_groups == 0: w_item = slice_w(space, ctx, ctx.match_start, ctx.match_end, w_emptystr) @@ -183,7 +183,7 @@ # scanner() method. ctx = self.make_ctx(w_string, pos, endpos) scanner = W_SRE_Scanner(self, ctx) - return self.space.wrap(scanner) + return scanner @unwrap_spec(maxsplit=int) def split_w(self, w_string, maxsplit=0): @@ -223,7 +223,7 @@ def subn_w(self, w_repl, w_string, count=0): w_item, n = self.subx(w_repl, w_string, count) space = self.space - return space.newtuple([w_item, space.wrap(n)]) + return space.newtuple([w_item, space.newint(n)]) def subx(self, w_ptemplate, w_string, count): space = self.space @@ -259,7 +259,7 @@ # not a literal; hand it over to the template compiler w_re = import_re(space) w_filter = space.call_method(w_re, '_subx', - space.wrap(self), w_ptemplate) + self, w_ptemplate) filter_is_callable = space.is_true(space.callable(w_filter)) # # XXX this is a bit of a mess, but it improves performance a lot @@ -377,7 +377,7 @@ def SRE_Pattern__new__(space, w_subtype, w_pattern, flags, w_code, groups=0, w_groupindex=None, w_indexgroup=None): n = space.len_w(w_code) - code = [intmask(space.uint_w(space.getitem(w_code, space.wrap(i)))) + code = [intmask(space.uint_w(space.getitem(w_code, space.newint(i)))) for i in range(n)] # w_srepat = space.allocate_instance(W_SRE_Pattern, w_subtype) @@ -474,22 +474,22 @@ def expand_w(self, w_template): space = self.space w_re = import_re(space) - return space.call_method(w_re, '_expand', space.wrap(self.srepat), - space.wrap(self), w_template) + return space.call_method(w_re, '_expand', self.srepat, + self, w_template) @unwrap_spec(w_groupnum=WrappedDefault(0)) def start_w(self, w_groupnum): - return self.space.wrap(self.do_span(w_groupnum)[0]) + return self.space.newint(self.do_span(w_groupnum)[0]) @unwrap_spec(w_groupnum=WrappedDefault(0)) def end_w(self, w_groupnum): - return self.space.wrap(self.do_span(w_groupnum)[1]) + return self.space.newint(self.do_span(w_groupnum)[1]) @unwrap_spec(w_groupnum=WrappedDefault(0)) def span_w(self, w_groupnum): start, end = self.do_span(w_groupnum) - return self.space.newtuple([self.space.wrap(start), - self.space.wrap(end)]) + return self.space.newtuple([self.space.newint(start), + self.space.newint(end)]) def flatten_marks(self): if self.flatten_cache is None: @@ -533,7 +533,7 @@ if lastindex < 0: return space.w_None w_result = space.finditem(self.srepat.w_indexgroup, - space.wrap(lastindex)) + space.newint(lastindex)) if w_result is None: return space.w_None return w_result @@ -541,14 +541,14 @@ def fget_lastindex(self, space): lastindex = self._last_index() if lastindex >= 0: - return space.wrap(lastindex) + return space.newint(lastindex) return space.w_None def fget_pos(self, space): - return space.wrap(self.ctx.original_pos) + return space.newint(self.ctx.original_pos) def fget_endpos(self, space): - return space.wrap(self.ctx.end) + return space.newint(self.ctx.end) def fget_regs(self, space): space = self.space @@ -556,11 +556,11 @@ num_groups = self.srepat.num_groups result_w = [None] * (num_groups + 1) ctx = self.ctx - result_w[0] = space.newtuple([space.wrap(ctx.match_start), - space.wrap(ctx.match_end)]) + result_w[0] = space.newtuple([space.newint(ctx.match_start), + space.newint(ctx.match_end)]) for i in range(num_groups): - result_w[i + 1] = space.newtuple([space.wrap(fmarks[i*2]), - space.wrap(fmarks[i*2+1])]) + result_w[i + 1] = space.newtuple([space.newint(fmarks[i*2]), + space.newint(fmarks[i*2+1])]) return space.newtuple(result_w) def fget_string(self, space): @@ -612,7 +612,7 @@ # or matching succeeded so far. def iter_w(self): - return self.space.wrap(self) + return self def next_w(self): if self.ctx.match_start > self.ctx.end: @@ -638,7 +638,7 @@ nextstart += (ctx.match_start == nextstart) self.ctx = ctx.fresh_copy(nextstart) match = W_SRE_Match(self.srepat, ctx) - return self.space.wrap(match) + return match else: self.ctx.match_start += 1 # obscure corner case return None _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit