Author: Armin Rigo <ar...@tunes.org> Branch: py3.5-newtext Changeset: r90091:dce0ae8e9a3e Date: 2017-02-13 17:00 +0100 http://bitbucket.org/pypy/pypy/changeset/dce0ae8e9a3e/
Log: hg merge 2601d8768d87 diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py --- a/pypy/goal/targetpypystandalone.py +++ b/pypy/goal/targetpypystandalone.py @@ -190,7 +190,7 @@ space.setitem(w_globals, space.newtext('__builtins__'), space.builtin_modules['builtins']) space.setitem(w_globals, space.newtext('c_argument'), - space.newbytes(c_argument)) + space.newint(c_argument)) space.appexec([space.newtext(source), w_globals], """(src, glob): import sys stmt = compile(src, 'c callback', 'exec') diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py --- a/pypy/interpreter/argument.py +++ b/pypy/interpreter/argument.py @@ -595,7 +595,7 @@ except IndexError: name = '?' else: - name = space.text_w(w_name) + name = space.identifier_w(w_name) break self.kwd_name = name diff --git a/pypy/interpreter/astcompiler/tools/asdl_py.py b/pypy/interpreter/astcompiler/tools/asdl_py.py --- a/pypy/interpreter/astcompiler/tools/asdl_py.py +++ b/pypy/interpreter/astcompiler/tools/asdl_py.py @@ -480,7 +480,7 @@ assert fields == [] def __spacebind__(self, space): - return space.newtuple([]) + return space.newtuple([space.newtext(field) for field in self.fields]) class W_AST(W_Root): diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py --- a/pypy/interpreter/baseobjspace.py +++ b/pypy/interpreter/baseobjspace.py @@ -52,7 +52,7 @@ w_dict = self.getdict(space) if w_dict is not None: try: - space.delitem(w_dict, space.wrap(attr)) + space.delitem(w_dict, space.newtext(attr)) return True except OperationError as ex: if not ex.match(space, space.w_KeyError): @@ -78,7 +78,7 @@ def getname(self, space): try: - return space.unicode_w(space.getattr(self, space.wrap('__name__'))) + return space.text_w(space.getattr(self, space.newtext('__name__'))) except OperationError as e: if e.match(space, space.w_TypeError) or e.match(space, space.w_AttributeError): return u'?' @@ -105,7 +105,7 @@ def getrepr(self, space, info, moreinfo=u''): addrstring = unicode(self.getaddrstring(space)) - return space.wrap(u"<%s at 0x%s%s>" % (info, addrstring, moreinfo)) + return space.newunicode(u"<%s at 0x%s%s>" % (info, addrstring, moreinfo)) def getslotvalue(self, index): raise NotImplementedError @@ -1849,7 +1849,7 @@ source = py.code.Source("def anonymous%s\n" % source) w_glob = space.newdict(module=True) space.exec_(str(source), w_glob, w_glob) - return space.getitem(w_glob, space.wrap('anonymous')) + return space.getitem(w_glob, space.newtext('anonymous')) # Table describing the regular part of the interface of object spaces, diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py --- a/pypy/interpreter/error.py +++ b/pypy/interpreter/error.py @@ -89,9 +89,8 @@ exc_typename = str(self.w_type) exc_value = str(w_value) else: - w = space.wrap - exc_typename = space.str_w( - space.getattr(self.w_type, w('__name__'))) + exc_typename = space.text_w( + space.getattr(self.w_type, space.newtext('__name__'))) if space.is_w(w_value, space.w_None): exc_value = "" else: diff --git a/pypy/interpreter/executioncontext.py b/pypy/interpreter/executioncontext.py --- a/pypy/interpreter/executioncontext.py +++ b/pypy/interpreter/executioncontext.py @@ -7,8 +7,8 @@ def app_profile_call(space, w_callable, frame, event, w_arg): space.call_function(w_callable, - space.wrap(frame), - space.wrap(event), w_arg) + frame, + space.newtext(event), w_arg) class ExecutionContext(object): """An ExecutionContext holds the state of an execution thread @@ -312,7 +312,7 @@ operr.normalize_exception(space) w_value = operr.get_w_value(space) w_arg = space.newtuple([operr.w_type, w_value, - space.wrap(operr.get_traceback())]) + operr.get_traceback()]) d = frame.getorcreatedebug() if d.w_locals is not None: @@ -323,7 +323,7 @@ self.is_tracing += 1 try: try: - w_result = space.call_function(w_callback, space.wrap(frame), space.wrap(event), w_arg) + w_result = space.call_function(w_callback, frame, space.newtext(event), w_arg) if space.is_w(w_result, space.w_None): # bug-to-bug compatibility with CPython # http://bugs.python.org/issue11992 @@ -601,7 +601,7 @@ msg = ("RPython exception %s in %s<%s at 0x%s> ignored\n" % ( str(e), where, space.type(w_obj).name, addrstring)) space.call_method(space.sys.get('stderr'), 'write', - space.wrap(msg)) + space.newtext(msg)) def make_finalizer_queue(W_Root, space): diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py --- a/pypy/interpreter/function.py +++ b/pypy/interpreter/function.py @@ -249,7 +249,7 @@ func = space.allocate_instance(Function, w_subtype) Function.__init__(func, space, code, w_globals, defs_w, None, closure, None,name) - return space.wrap(func) + return func def descr_function_call(self, __args__): return self.call_args(__args__) @@ -289,14 +289,13 @@ if isinstance(code, BuiltinCode): new_inst = mod.get('builtin_function') return space.newtuple([new_inst, - space.newtuple([space.wrap(code.identifier)])]) + space.newtuple([space.newtext(code.identifier)])]) new_inst = mod.get('func_new') - w = space.wrap if self.closure is None: w_closure = space.w_None else: - w_closure = space.newtuple([w(cell) for cell in self.closure]) + w_closure = space.newtuple([cell for cell in self.closure]) if self.w_doc is None: w_doc = space.w_None else: @@ -313,10 +312,10 @@ nt = space.newtuple tup_base = [] tup_state = [ - w(self.name), - w(self.qualname), + space.newtext(self.name), + space.newunicode(self.qualname), w_doc, - w(self.code), + self.code, w_func_globals, w_closure, nt(self.defs_w), @@ -337,8 +336,8 @@ "Wrong arguments to function.__setstate__") self.space = space - self.name = space.str_w(w_name) - self.qualname = space.str_w(w_qualname).decode("utf-8") + self.name = space.text_w(w_name) + self.qualname = space.unicode_w(w_qualname) self.code = space.interp_w(Code, w_code) if not space.is_w(w_closure, space.w_None): from pypy.interpreter.nestedscope import Cell @@ -421,7 +420,7 @@ self.w_doc = w_doc def fget_func_name(self, space): - return space.wrap(self.name.decode('utf-8')) + return space.newtext(self.name) def fset_func_name(self, space, w_name): if space.isinstance_w(w_name, space.w_unicode): @@ -431,7 +430,7 @@ "__name__ must be set to a string object") def fget_func_qualname(self, space): - return space.wrap(self.qualname) + return space.newunicode(self.qualname) def fset_func_qualname(self, space, w_name): try: @@ -448,7 +447,7 @@ def fget___module__(self, space): if self.w_module is None: if self.w_func_globals is not None and not space.is_w(self.w_func_globals, space.w_None): - self.w_module = space.call_method(self.w_func_globals, "get", space.wrap("__name__")) + self.w_module = space.call_method(self.w_func_globals, "get", space.newtext("__name__")) else: self.w_module = space.w_None return self.w_module @@ -460,7 +459,7 @@ self.w_module = space.w_None def fget_func_code(self, space): - return space.wrap(self.code) + return self.code def fset_func_code(self, space, w_code): from pypy.interpreter.pycode import PyCode @@ -480,7 +479,7 @@ def fget_func_closure(self, space): if self.closure is not None: - w_res = space.newtuple([space.wrap(i) for i in self.closure]) + w_res = space.newtuple([cell for cell in self.closure]) else: w_res = space.w_None return w_res @@ -508,7 +507,7 @@ if w_obj is None or space.is_w(w_obj, space.w_None): return w_function else: - return space.wrap(Method(space, w_function, w_obj)) + return Method(space, w_function, w_obj) class Method(W_Root): @@ -527,7 +526,7 @@ raise oefmt(space.w_TypeError, "self must not be None") method = space.allocate_instance(Method, w_subtype) Method.__init__(method, space, w_function, w_instance) - return space.wrap(method) + return method def __repr__(self): return u"bound method %s" % (self.w_function.getname(self.space),) @@ -537,14 +536,14 @@ return space.call_obj_args(self.w_function, self.w_instance, args) def descr_method_get(self, w_obj, w_cls=None): - return self.space.wrap(self) # already bound + return self # already bound def descr_method_call(self, __args__): return self.call_args(__args__) def descr_method_repr(self): space = self.space - w_name = space.findattr(self.w_function, space.wrap('__qualname__')) + w_name = space.findattr(self.w_function, space.newtext('__qualname__')) if w_name is None: name = self.w_function.getname(self.space) else: @@ -556,14 +555,14 @@ name = u'?' objrepr = space.unicode_w(space.repr(self.w_instance)) s = u'<bound method %s of %s>' % (name, objrepr) - return space.wrap(s) + return space.newunicode(s) def descr_method_getattribute(self, w_attr): space = self.space if space.str_w(w_attr) != '__doc__': try: return space.call_method(space.w_object, '__getattribute__', - space.wrap(self), w_attr) + self, w_attr) except OperationError as e: if not e.match(space, space.w_AttributeError): raise @@ -612,7 +611,7 @@ if (isinstance(w_function, Function) and isinstance(w_function.code, BuiltinCode)): new_inst = mod.get('builtin_method_new') - tup = [w_instance, space.wrap(w_function.name)] + tup = [w_instance, space.newtext(w_function.name)] else: new_inst = mod.get('method_new') tup = [self.w_function, w_instance] @@ -678,7 +677,7 @@ def descr_classmethod_get(self, space, w_obj, w_klass=None): if space.is_none(w_klass): w_klass = space.type(w_obj) - return space.wrap(Method(space, self.w_function, w_klass)) + return Method(space, self.w_function, w_klass) def descr_classmethod__new__(space, w_subtype, w_function): instance = space.allocate_instance(ClassMethod, w_subtype) @@ -713,10 +712,10 @@ "cannot create 'builtin_function' instances") def descr_function_repr(self): - return self.space.wrap('<built-in function %s>' % (self.name,)) + return self.space.newtext('<built-in function %s>' % (self.name,)) def descr__reduce__(self, space): - return space.wrap(self.qualname) + return space.newunicode(self.qualname) def is_builtin_code(w_func): from pypy.interpreter.gateway import BuiltinCode diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py --- a/pypy/interpreter/gateway.py +++ b/pypy/interpreter/gateway.py @@ -731,7 +731,7 @@ mod = space.interp_w(MixedModule, w_mod) builtin_code = mod.get('builtin_code') return space.newtuple([builtin_code, - space.newtuple([space.wrap(self.identifier)])]) + space.newtuple([space.newtext(self.identifier)])]) @staticmethod def find(space, identifier): @@ -742,7 +742,7 @@ return self.sig def getdocstring(self, space): - return space.wrap(self.docstring) + return space.newtext(self.docstring) def funcrun(self, func, args): return BuiltinCode.funcrun_obj(self, func, None, args) @@ -1135,11 +1135,11 @@ def buildmodule(self, space, name='applevel'): from pypy.interpreter.module import Module - return Module(space, space.wrap(name), self.getwdict(space)) + return Module(space, space.newtext(name), self.getwdict(space)) def wget(self, space, name): w_globals = self.getwdict(space) - return space.getitem(w_globals, space.wrap(name)) + return space.getitem(w_globals, space.newtext(name)) def interphook(self, name): "NOT_RPYTHON" @@ -1189,7 +1189,7 @@ def build_applevel_dict(self, space): "NOT_RPYTHON" w_glob = space.newdict(module=True) - space.setitem(w_glob, space.wrap('__name__'), space.wrap(self.modname)) + space.setitem(w_glob, space.newtext('__name__'), space.newtext(self.modname)) space.exec_(self.source, w_glob, w_glob, hidden_applevel=self.hidden_applevel, filename=self.filename) diff --git a/pypy/interpreter/interactive.py b/pypy/interpreter/interactive.py --- a/pypy/interpreter/interactive.py +++ b/pypy/interpreter/interactive.py @@ -93,13 +93,13 @@ mainmodule = main.ensure__main__(space) self.w_globals = mainmodule.w_dict - space.setitem(self.w_globals, space.wrap('__builtins__'), space.builtin) + space.setitem(self.w_globals, space.newtext('__builtins__'), space.builtin) if completer: self.enable_command_line_completer() # forbidden: #space.exec_("__pytrace__ = 0", self.w_globals, self.w_globals) - space.setitem(self.w_globals, space.wrap('__pytrace__'),space.newint(0)) + space.setitem(self.w_globals, space.newtext('__pytrace__'),space.newint(0)) self.tracelevel = 0 self.console_locals = {} @@ -159,7 +159,7 @@ for name in local: if name.startswith('w_'): self.space.setitem(self.w_globals, - self.space.wrap(name[2:]), + self.space.newtext(name[2:]), local[name]) print '*** Leaving interpreter-level console ***' raise diff --git a/pypy/interpreter/main.py b/pypy/interpreter/main.py --- a/pypy/interpreter/main.py +++ b/pypy/interpreter/main.py @@ -4,7 +4,7 @@ def ensure__main__(space): - w_main = space.wrap('__main__') + w_main = space.newtext('__main__') w_modules = space.sys.get('modules') try: return space.getitem(w_modules, w_main) @@ -17,10 +17,9 @@ def compilecode(space, source, filename, cmd='exec'): - w = space.wrap w_code = space.builtin.call( 'compile', space.newbytes(source), space.wrap_fsdecoded(filename), - w(cmd), w(0), w(0)) + space.wrap(cmd), space.newint(0), space.newint(0)) pycode = space.interp_w(eval.Code, w_code) return pycode @@ -36,16 +35,14 @@ from pypy.objspace.std import StdObjSpace space = StdObjSpace() - w = space.wrap - pycode = compilecode(space, source, filename or '<string>', cmd) mainmodule = ensure__main__(space) w_globals = mainmodule.w_dict - space.setitem(w_globals, w('__builtins__'), space.builtin) + space.setitem(w_globals, space.newtext('__builtins__'), space.builtin) if filename is not None: - space.setitem(w_globals, w('__file__'), + space.setitem(w_globals, space.newtext('__file__'), space.wrap_fsdecoded(filename)) retval = pycode.exec_code(space, w_globals, w_globals) @@ -85,16 +82,15 @@ if space is None: from pypy.objspace.std import StdObjSpace space = StdObjSpace() - w = space.wrap argv = [module_name] if args is not None: argv.extend(args) - space.setitem(space.sys.w_dict, w('argv'), w(argv)) + space.setitem(space.sys.w_dict, space.newtext('argv'), space.wrap(argv)) w_import = space.builtin.get('__import__') - runpy = space.call_function(w_import, w('runpy')) - w_run_module = space.getitem(runpy.w_dict, w('run_module')) - return space.call_function(w_run_module, w(module_name), space.w_None, - w('__main__'), space.w_True) + runpy = space.call_function(w_import, space.wrap('runpy')) + w_run_module = space.getitem(runpy.w_dict, space.wrap('run_module')) + return space.call_function(w_run_module, space.wrap(module_name), space.w_None, + space.wrap('__main__'), space.w_True) def run_toplevel(space, f, verbose=False): @@ -121,7 +117,7 @@ # exit if we catch a w_SystemExit if operationerr.match(space, space.w_SystemExit): w_exitcode = space.getattr(w_value, - space.wrap('code')) + space.newtext('code')) if space.is_w(w_exitcode, space.w_None): exitcode = 0 else: @@ -135,9 +131,9 @@ raise SystemExit(exitcode) # set the sys.last_xxx attributes - space.setitem(space.sys.w_dict, space.wrap('last_type'), w_type) - space.setitem(space.sys.w_dict, space.wrap('last_value'), w_value) - space.setitem(space.sys.w_dict, space.wrap('last_traceback'), + space.setitem(space.sys.w_dict, space.newtext('last_type'), w_type) + space.setitem(space.sys.w_dict, space.newtext('last_value'), w_value) + space.setitem(space.sys.w_dict, space.newtext('last_traceback'), w_traceback) # call sys.excepthook if present diff --git a/pypy/interpreter/mixedmodule.py b/pypy/interpreter/mixedmodule.py --- a/pypy/interpreter/mixedmodule.py +++ b/pypy/interpreter/mixedmodule.py @@ -34,7 +34,7 @@ for sub_name, module_cls in self.submodules.iteritems(): if module_cls.submodule_name is None: module_cls.submodule_name = sub_name - module_name = space.wrap("%s.%s" % (name, sub_name)) + module_name = space.newtext("%s.%s" % (name, sub_name)) m = module_cls(space, module_name) m.install() self.submodules_w.append(m) @@ -50,7 +50,7 @@ for w_submodule in self.submodules_w: name = space.str0_w(w_submodule.w_name) - space.setitem(self.w_dict, space.wrap(name.split(".")[-1]), w_submodule) + space.setitem(self.w_dict, space.newtext(name.split(".")[-1]), w_submodule) space.getbuiltinmodule(name) if self.w_initialdict is None: @@ -77,7 +77,7 @@ space = self.space w_value = self.getdictvalue(space, name) if w_value is None: - raise OperationError(space.w_AttributeError, space.wrap(name)) + raise OperationError(space.w_AttributeError, space.newtext(name)) return w_value def call(self, name, *args_w): @@ -186,7 +186,7 @@ loader = getinterpevalloader(pkgroot, spec) space = self.space w_obj = loader(space) - space.setattr(space.wrap(self), space.wrap(name), w_obj) + space.setattr(self, space.newtext(name), w_obj) @classmethod def get__doc__(cls, space): diff --git a/pypy/interpreter/module.py b/pypy/interpreter/module.py --- a/pypy/interpreter/module.py +++ b/pypy/interpreter/module.py @@ -31,15 +31,14 @@ statically inside the executable.""" try: space = self.space - space.delitem(self.w_dict, space.wrap('__file__')) + space.delitem(self.w_dict, space.newtext('__file__')) except OperationError: pass def install(self): """NOT_RPYTHON: installs this module into space.builtin_modules""" - w_mod = self.space.wrap(self) modulename = self.space.str0_w(self.w_name) - self.space.builtin_modules[modulename] = w_mod + self.space.builtin_modules[modulename] = self def setup_after_space_initialization(self): """NOT_RPYTHON: to allow built-in modules to do some more setup diff --git a/pypy/interpreter/nestedscope.py b/pypy/interpreter/nestedscope.py --- a/pypy/interpreter/nestedscope.py +++ b/pypy/interpreter/nestedscope.py @@ -60,7 +60,7 @@ space.newtuple(tup)]) def descr__setstate__(self, space, w_state): - self.w_value = space.getitem(w_state, space.wrap(0)) + self.w_value = space.getitem(w_state, space.newint(0)) def __repr__(self): """ representation for debugging purposes """ @@ -78,7 +78,7 @@ content = "%s object at 0x%s" % (space.type(self.w_value).name, self.w_value.getaddrstring(space)) s = "<cell at 0x%s: %s>" % (self.getaddrstring(space), content) - return space.wrap(s.decode('utf-8')) + return space.newtext(s) def descr__cell_contents(self, space): try: diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py --- a/pypy/interpreter/pycode.py +++ b/pypy/interpreter/pycode.py @@ -367,7 +367,7 @@ for name in self.co_varnames: result ^= compute_hash(name) for name in self.co_freevars: result ^= compute_hash(name) for name in self.co_cellvars: result ^= compute_hash(name) - w_result = space.wrap(intmask(result)) + w_result = space.newint(intmask(result)) for w_name in self.co_names_w: w_result = space.xor(w_result, space.hash(w_name)) for w_const in self.co_consts_w: @@ -409,31 +409,30 @@ code = space.allocate_instance(PyCode, w_subtype) PyCode.__init__(code, space, argcount, kwonlyargcount, nlocals, stacksize, flags, codestring, consts_w[:], names, varnames, filename, name, firstlineno, lnotab, freevars, cellvars, magic=magic) - return space.wrap(code) + return code def descr__reduce__(self, space): from pypy.interpreter.mixedmodule import MixedModule w_mod = space.getbuiltinmodule('_pickle_support') mod = space.interp_w(MixedModule, w_mod) new_inst = mod.get('code_new') - w = space.wrap tup = [ - w(self.co_argcount), - w(self.co_kwonlyargcount), - w(self.co_nlocals), - w(self.co_stacksize), - w(self.co_flags), + space.newint(self.co_argcount), + space.newint(self.co_kwonlyargcount), + space.newint(self.co_nlocals), + space.newint(self.co_stacksize), + space.newint(self.co_flags), space.newbytes(self.co_code), space.newtuple(self.co_consts_w), space.newtuple(self.co_names_w), - space.newtuple([w(v) for v in self.co_varnames]), - w(self.co_filename), - w(self.co_name), - w(self.co_firstlineno), + space.newtuple([space.newtext(v) for v in self.co_varnames]), + space.newtext(self.co_filename), + space.newtext(self.co_name), + space.newint(self.co_firstlineno), space.newbytes(self.co_lnotab), - space.newtuple([w(v) for v in self.co_freevars]), - space.newtuple([w(v) for v in self.co_cellvars]), - w(self.magic), + space.newtuple([space.newtext(v) for v in self.co_freevars]), + space.newtuple([space.newtext(v) for v in self.co_cellvars]), + space.newint(self.magic), ] return space.newtuple([new_inst, space.newtuple(tup)]) @@ -452,6 +451,6 @@ # co_name should be an identifier name = self.co_name.decode('utf-8') fn = space.fsdecode_w(space.newbytes(self.co_filename)) - return space.wrap(u'<code object %s at 0x%s, file "%s", line %d>' % ( + return space.newunicode(u'<code object %s at 0x%s, file "%s", line %d>' % ( name, unicode(self.getaddrstring(space)), fn, -1 if self.co_firstlineno == 0 else self.co_firstlineno)) diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py --- a/pypy/interpreter/pyframe.py +++ b/pypy/interpreter/pyframe.py @@ -293,7 +293,7 @@ self.f_generator_wref = rweakref.ref(gen) else: self.f_generator_nowref = gen - w_gen = space.wrap(gen) + w_gen = gen if w_wrapper is not None: if ec.in_coroutine_wrapper: @@ -535,7 +535,7 @@ if w_value is not None: self.space.setitem_str(d.w_locals, name, w_value) else: - w_name = self.space.wrap(name.decode('utf-8')) + w_name = self.space.newtext(name) try: self.space.delitem(d.w_locals, w_name) except OperationError as e: @@ -613,7 +613,7 @@ return None def fget_code(self, space): - return space.wrap(self.getcode()) + return self.getcode() def fget_getdictscope(self, space): return self.getdictscope() @@ -628,9 +628,9 @@ def fget_f_lineno(self, space): "Returns the line number of the instruction currently being executed." if self.get_w_f_trace() is None: - return space.wrap(self.get_last_lineno()) + return space.newint(self.get_last_lineno()) else: - return space.wrap(self.getorcreatedebug().f_lineno) + return space.newint(self.getorcreatedebug().f_lineno) def fset_f_lineno(self, space, w_new_lineno): "Change the line number of the instruction currently being executed." @@ -774,10 +774,10 @@ def fget_f_back(self, space): f_back = ExecutionContext.getnextframe_nohidden(self) - return self.space.wrap(f_back) + return f_back def fget_f_lasti(self, space): - return self.space.wrap(self.last_instr) + return self.space.newint(self.last_instr) def fget_f_trace(self, space): return self.get_w_f_trace() @@ -795,7 +795,7 @@ def fget_f_restricted(self, space): if space.config.objspace.honor__builtins__: - return space.wrap(self.builtin is not space.builtin) + return space.newbool(self.builtin is not space.builtin) return space.w_False def get_generator(self): diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -86,7 +86,7 @@ rstackovf.check_stack_overflow() next_instr = self.handle_asynchronous_error(ec, self.space.w_RecursionError, - self.space.wrap("maximum recursion depth exceeded")) + self.space.newtext("maximum recursion depth exceeded")) return next_instr def handle_asynchronous_error(self, ec, w_type, w_value=None): @@ -557,18 +557,17 @@ def raise_exc_unbound(self, varindex): varname = self.getfreevarname(varindex) if self.iscellvar(varindex): - message = "local variable '%s' referenced before assignment"%varname - w_exc_type = self.space.w_UnboundLocalError + raise oefmt(self.space.w_UnboundLocalError, + "local variable '%s' referenced before assignment", + varname) else: - message = ("free variable '%s' referenced before assignment" - " in enclosing scope"%varname) - w_exc_type = self.space.w_NameError - raise OperationError(w_exc_type, self.space.wrap(message)) + raise oefmt(self.space.w_NameError, + "free variable '%s' referenced before assignment" + " in enclosing scope", varname) def LOAD_CLOSURE(self, varindex, next_instr): # nested scopes: access the cell object - cell = self._getcell(varindex) - w_value = self.space.wrap(cell) + w_value = self._getcell(varindex) self.pushvalue(w_value) def POP_TOP(self, oparg, next_instr): @@ -1227,7 +1226,7 @@ if isinstance(w_unroller, SApplicationException): # app-level exception operr = w_unroller.operr - w_traceback = self.space.wrap(operr.get_traceback()) + w_traceback = operr.get_traceback() w_res = self.call_contextmanager_exit_function( w_exitfunc, operr.w_type, @@ -1341,7 +1340,7 @@ fn = function.Function(space, codeobj, self.get_w_globals(), defaultarguments, kw_defs_w, freevars, w_ann, qualname=qualname) - self.pushvalue(space.wrap(fn)) + self.pushvalue(fn) def MAKE_FUNCTION(self, oparg, next_instr): return self._make_function(oparg) @@ -1830,7 +1829,7 @@ assert isinstance(unroller, SApplicationException) operationerr = unroller.operr operationerr.normalize_exception(frame.space) - frame.pushvalue(frame.space.wrap(unroller)) + frame.pushvalue(unroller) frame.pushvalue(operationerr.get_w_value(frame.space)) frame.pushvalue(operationerr.w_type) # set the current value of sys_exc_info to operationerr, @@ -1855,7 +1854,7 @@ if isinstance(unroller, SApplicationException): operationerr = unroller.operr operationerr.normalize_exception(frame.space) - frame.pushvalue(frame.space.wrap(unroller)) + frame.pushvalue(unroller) # set the current value of sys_exc_info to operationerr, # saving the old value in a custom type of FrameBlock frame.save_and_change_sys_exc_info(operationerr) diff --git a/pypy/interpreter/pyparser/error.py b/pypy/interpreter/pyparser/error.py --- a/pypy/interpreter/pyparser/error.py +++ b/pypy/interpreter/pyparser/error.py @@ -28,15 +28,15 @@ if len(self.text) != offset: text, _ = str_decode_utf_8(self.text, len(self.text), 'replace') - w_text = space.wrap(text) + w_text = space.newtext(text) if self.filename is not None: w_filename = space.wrap_fsdecoded(self.filename) return space.newtuple([space.wrap(self.msg), space.newtuple([w_filename, - space.wrap(self.lineno), - space.wrap(offset), + space.newint(self.lineno), + space.newint(offset), w_text, - space.wrap(self.lastlineno)])]) + space.newint(self.lastlineno)])]) def __str__(self): return "%s at pos (%d, %d) in %r" % (self.__class__.__name__, diff --git a/pypy/interpreter/pytraceback.py b/pypy/interpreter/pytraceback.py --- a/pypy/interpreter/pytraceback.py +++ b/pypy/interpreter/pytraceback.py @@ -24,20 +24,19 @@ return offset2lineno(self.frame.pycode, self.lasti) def descr_tb_lineno(self, space): - return space.wrap(self.get_lineno()) + return space.newint(self.get_lineno()) def descr__reduce__(self, space): from pypy.interpreter.mixedmodule import MixedModule w_mod = space.getbuiltinmodule('_pickle_support') mod = space.interp_w(MixedModule, w_mod) new_inst = mod.get('traceback_new') - w = space.wrap tup_base = [] tup_state = [ - w(self.frame), - w(self.lasti), - w(self.next), + self.frame, + space.newint(self.lasti), + self.next, ] nt = space.newtuple return nt([new_inst, nt(tup_base), nt(tup_state)]) @@ -65,5 +64,5 @@ def check_traceback(space, w_tb, msg): if w_tb is None or not space.isinstance_w(w_tb, space.gettypeobject(PyTraceback.typedef)): - raise OperationError(space.w_TypeError, space.wrap(msg)) + raise OperationError(space.w_TypeError, space.newtext(msg)) return w_tb diff --git a/pypy/interpreter/special.py b/pypy/interpreter/special.py --- a/pypy/interpreter/special.py +++ b/pypy/interpreter/special.py @@ -8,7 +8,7 @@ return space.w_Ellipsis def descr__repr__(self, space): - return space.wrap('Ellipsis') + return space.newtext('Ellipsis') descr__reduce__ = descr__repr__ @@ -20,6 +20,6 @@ return space.w_NotImplemented def descr__repr__(self, space): - return space.wrap('NotImplemented') + return space.newtext('NotImplemented') descr__reduce__ = descr__repr__ diff --git a/pypy/interpreter/streamutil.py b/pypy/interpreter/streamutil.py --- a/pypy/interpreter/streamutil.py +++ b/pypy/interpreter/streamutil.py @@ -4,7 +4,7 @@ def wrap_streamerror(space, e, w_filename=None): if isinstance(e, StreamError): return OperationError(space.w_ValueError, - space.wrap(e.message)) + space.newtext(e.message)) elif isinstance(e, OSError): return wrap_oserror_as_ioerror(space, e, w_filename) else: diff --git a/pypy/interpreter/test/test_argument.py b/pypy/interpreter/test/test_argument.py --- a/pypy/interpreter/test/test_argument.py +++ b/pypy/interpreter/test/test_argument.py @@ -94,6 +94,7 @@ def wrap(self, obj): return obj + newtext = wrap def str_w(self, s): return str(s) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit