Author: Carl Friedrich Bolz <cfb...@gmx.de> Branch: space-newtext Changeset: r88069:25160182f5b3 Date: 2016-11-02 12:38 +0100 http://bitbucket.org/pypy/pypy/changeset/25160182f5b3/
Log: __pypy__ diff --git a/pypy/module/__pypy__/interp_builders.py b/pypy/module/__pypy__/interp_builders.py --- a/pypy/module/__pypy__/interp_builders.py +++ b/pypy/module/__pypy__/interp_builders.py @@ -6,7 +6,7 @@ from rpython.tool.sourcetools import func_with_new_name -def create_builder(name, strtype, builder_cls): +def create_builder(name, strtype, builder_cls, newmethod): class W_Builder(W_Root): def __init__(self, space, size): if size < 0: @@ -37,14 +37,14 @@ def descr_build(self, space): self._check_done(space) - w_s = space.wrap(self.builder.build()) + w_s = getattr(space, newmethod)(self.builder.build()) self.builder = None return w_s def descr_len(self, space): if self.builder is None: raise oefmt(space.w_ValueError, "no length of built builder") - return space.wrap(self.builder.getlength()) + return space.newint(self.builder.getlength()) W_Builder.__name__ = "W_%s" % name W_Builder.typedef = TypeDef(name, @@ -59,5 +59,5 @@ W_Builder.typedef.acceptable_as_base_class = False return W_Builder -W_StringBuilder = create_builder("StringBuilder", str, StringBuilder) -W_UnicodeBuilder = create_builder("UnicodeBuilder", unicode, UnicodeBuilder) +W_StringBuilder = create_builder("StringBuilder", str, StringBuilder, "newbytes") +W_UnicodeBuilder = create_builder("UnicodeBuilder", unicode, UnicodeBuilder, "newunicode") diff --git a/pypy/module/__pypy__/interp_identitydict.py b/pypy/module/__pypy__/interp_identitydict.py --- a/pypy/module/__pypy__/interp_identitydict.py +++ b/pypy/module/__pypy__/interp_identitydict.py @@ -11,13 +11,13 @@ def descr_new(space, w_subtype): self = space.allocate_instance(W_IdentityDict, w_subtype) W_IdentityDict.__init__(self, space) - return space.wrap(self) + return self def descr_len(self, space): - return space.wrap(len(self.dict)) + return space.newint(len(self.dict)) def descr_contains(self, space, w_key): - return space.wrap(w_key in self.dict) + return space.newbool(w_key in self.dict) def descr_setitem(self, space, w_key, w_value): self.dict[w_key] = w_value diff --git a/pypy/module/__pypy__/interp_intop.py b/pypy/module/__pypy__/interp_intop.py --- a/pypy/module/__pypy__/interp_intop.py +++ b/pypy/module/__pypy__/interp_intop.py @@ -8,34 +8,34 @@ @unwrap_spec(n=int, m=int) def int_add(space, n, m): - return space.wrap(llop.int_add(lltype.Signed, n, m)) + return space.newint(llop.int_add(lltype.Signed, n, m)) @unwrap_spec(n=int, m=int) def int_sub(space, n, m): - return space.wrap(llop.int_sub(lltype.Signed, n, m)) + return space.newint(llop.int_sub(lltype.Signed, n, m)) @unwrap_spec(n=int, m=int) def int_mul(space, n, m): - return space.wrap(llop.int_mul(lltype.Signed, n, m)) + return space.newint(llop.int_mul(lltype.Signed, n, m)) @unwrap_spec(n=int, m=int) def int_floordiv(space, n, m): - return space.wrap(int_c_div(n, m)) + return space.newint(int_c_div(n, m)) @unwrap_spec(n=int, m=int) def int_mod(space, n, m): - return space.wrap(int_c_mod(n, m)) + return space.newint(int_c_mod(n, m)) @unwrap_spec(n=int, m=int) def int_lshift(space, n, m): - return space.wrap(llop.int_lshift(lltype.Signed, n, m)) + return space.newint(llop.int_lshift(lltype.Signed, n, m)) @unwrap_spec(n=int, m=int) def int_rshift(space, n, m): - return space.wrap(llop.int_rshift(lltype.Signed, n, m)) + return space.newint(llop.int_rshift(lltype.Signed, n, m)) @unwrap_spec(n=int, m=int) def uint_rshift(space, n, m): n = r_uint(n) x = llop.uint_rshift(lltype.Unsigned, n, m) - return space.wrap(intmask(x)) + return space.newint(intmask(x)) diff --git a/pypy/module/__pypy__/interp_magic.py b/pypy/module/__pypy__/interp_magic.py --- a/pypy/module/__pypy__/interp_magic.py +++ b/pypy/module/__pypy__/interp_magic.py @@ -13,7 +13,7 @@ def internal_repr(space, w_object): - return space.wrap('%r' % (w_object,)) + return space.newtext('%r' % (w_object,)) def attach_gdb(space): @@ -59,7 +59,7 @@ from pypy.interpreter.function import Function, BuiltinFunction func = space.interp_w(Function, w_func) bltn = BuiltinFunction(func) - return space.wrap(bltn) + return bltn def hidden_applevel(space, w_func): """Decorator that hides a function's frame from app-level""" @@ -73,7 +73,7 @@ frame hidden from applevel. """ operr = space.getexecutioncontext().sys_exc_info(for_hidden=True) - return space.w_None if operr is None else space.wrap(operr.get_traceback()) + return space.w_None if operr is None else operr.get_traceback() @unwrap_spec(meth=str) def lookup_special(space, w_obj, meth): @@ -87,7 +87,7 @@ return space.get(w_descr, w_obj) def do_what_I_mean(space): - return space.wrap(42) + return space.newint(42) def strategy(space, w_obj): @@ -103,7 +103,7 @@ name = w_obj.strategy.__class__.__name__ else: raise oefmt(space.w_TypeError, "expecting dict or list or set object") - return space.wrap(name) + return space.newtext(name) @unwrap_spec(fd='c_int') @@ -116,8 +116,8 @@ def get_console_cp(space): from rpython.rlib import rwin32 # Windows only return space.newtuple([ - space.wrap('cp%d' % rwin32.GetConsoleCP()), - space.wrap('cp%d' % rwin32.GetConsoleOutputCP()), + space.newtext('cp%d' % rwin32.GetConsoleCP()), + space.newtext('cp%d' % rwin32.GetConsoleOutputCP()), ]) @unwrap_spec(sizehint=int) @@ -134,8 +134,8 @@ def set_debug(space, debug): space.sys.debug = debug space.setitem(space.builtin.w_dict, - space.wrap('__debug__'), - space.wrap(debug)) + space.newtext('__debug__'), + space.newbool(debug)) @unwrap_spec(estimate=int) def add_memory_pressure(estimate): diff --git a/pypy/module/__pypy__/interp_os.py b/pypy/module/__pypy__/interp_os.py --- a/pypy/module/__pypy__/interp_os.py +++ b/pypy/module/__pypy__/interp_os.py @@ -6,4 +6,4 @@ @unwrap_spec(name='str0') def real_getenv(space, name): """Get an OS environment value skipping Python cache""" - return space.wrap(os.environ.get(name)) + return space.newtext_or_none(os.environ.get(name)) diff --git a/pypy/module/__pypy__/interp_time.py b/pypy/module/__pypy__/interp_time.py --- a/pypy/module/__pypy__/interp_time.py +++ b/pypy/module/__pypy__/interp_time.py @@ -18,7 +18,7 @@ raise exception_from_saved_errno(space, space.w_IOError) t = (float(rffi.getintfield(tp, 'c_tv_sec')) + float(rffi.getintfield(tp, 'c_tv_nsec')) * 0.000000001) - return space.wrap(t) + return space.newfloat(t) @unwrap_spec(clk_id="c_int") def clock_getres(space, clk_id): @@ -28,4 +28,4 @@ raise exception_from_saved_errno(space, space.w_IOError) t = (float(rffi.getintfield(tp, 'c_tv_sec')) + float(rffi.getintfield(tp, 'c_tv_nsec')) * 0.000000001) - return space.wrap(t) + return space.newfloat(t) diff --git a/pypy/module/binascii/interp_hqx.py b/pypy/module/binascii/interp_hqx.py --- a/pypy/module/binascii/interp_hqx.py +++ b/pypy/module/binascii/interp_hqx.py @@ -97,7 +97,7 @@ else: if pending_bits > 0: raise_Incomplete(space, 'String has incomplete number of bytes') - return space.newtuple([space.newbytes(res.build()), space.wrap(done)]) + return space.newtuple([space.newbytes(res.build()), space.newint(done)]) # ____________________________________________________________ @@ -242,4 +242,4 @@ crc = oldcrc for c in data: crc = ((crc << 8) & 0xff00) ^ crctab_hqx[((crc >> 8) & 0xff) ^ ord(c)] - return space.wrap(crc) + return space.newint(crc) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit