Author: Armin Rigo <ar...@tunes.org> Branch: py3.5-newtext Changeset: r90141:6b32e82270a9 Date: 2017-02-15 09:16 +0100 http://bitbucket.org/pypy/pypy/changeset/6b32e82270a9/
Log: hg merge ffe62ff416aa diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py --- a/pypy/goal/targetpypystandalone.py +++ b/pypy/goal/targetpypystandalone.py @@ -83,7 +83,7 @@ except OperationError as e: debug("OperationError:") debug(" operror-type: " + e.w_type.getname(space).encode('utf-8')) - debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space)))) + debug(" operror-value: " + space.text_w(space.str(e.get_w_value(space)))) return 1 finally: try: @@ -91,7 +91,7 @@ except OperationError as e: debug("OperationError:") debug(" operror-type: " + e.w_type.getname(space).encode('utf-8')) - debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space)))) + debug(" operror-value: " + space.text_w(space.str(e.get_w_value(space)))) return 1 return exitcode @@ -148,7 +148,7 @@ if verbose: debug("OperationError:") debug(" operror-type: " + e.w_type.getname(space).encode('utf-8')) - debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space)))) + debug(" operror-value: " + space.text_w(space.str(e.get_w_value(space)))) return rffi.cast(rffi.INT, -1) finally: if must_leave: @@ -202,7 +202,7 @@ except OperationError as e: debug("OperationError:") debug(" operror-type: " + e.w_type.getname(space).encode('utf-8')) - debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space)))) + debug(" operror-value: " + space.text_w(space.str(e.get_w_value(space)))) return -1 return 0 diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py --- a/pypy/interpreter/error.py +++ b/pypy/interpreter/error.py @@ -97,9 +97,9 @@ else: try: if use_repr: - exc_value = space.str_w(space.repr(w_value)) + exc_value = space.text_w(space.repr(w_value)) else: - exc_value = space.str_w(space.str(w_value)) + exc_value = space.text_w(space.str(w_value)) except OperationError: # oups, cannot __str__ the exception object exc_value = ("<exception %s() failed>" % @@ -259,7 +259,7 @@ objrepr = '' else: try: - objrepr = space.str_w(space.repr(w_object)) + objrepr = space.text_w(space.repr(w_object)) except OperationError: objrepr = "<object repr() failed>" # diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py --- a/pypy/interpreter/function.py +++ b/pypy/interpreter/function.py @@ -222,7 +222,7 @@ if not space.isinstance_w(w_globals, space.w_dict): raise oefmt(space.w_TypeError, "expected dict") if not space.is_none(w_name): - name = space.str_w(w_name) + name = space.text_w(w_name) else: name = None if not space.is_none(w_argdefs): @@ -423,8 +423,8 @@ return space.newtext(self.name) def fset_func_name(self, space, w_name): - if space.isinstance_w(w_name, space.w_unicode): - self.name = space.str_w(w_name) + if space.isinstance_w(w_name, space.w_text): + self.name = space.text_w(w_name) else: raise oefmt(space.w_TypeError, "__name__ must be set to a string object") @@ -559,7 +559,7 @@ def descr_method_getattribute(self, w_attr): space = self.space - if space.str_w(w_attr) != '__doc__': + if space.text_w(w_attr) != '__doc__': try: return space.call_method(space.w_object, '__getattribute__', self, w_attr) diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -1026,6 +1026,7 @@ def IMPORT_NAME(self, nameindex, next_instr): space = self.space w_modulename = self.getname_w(nameindex) + modulename = self.space.text_w(w_modulename) w_fromlist = self.popvalue() w_flag = self.popvalue() @@ -1046,6 +1047,7 @@ w_locals = d.w_locals if w_locals is None: # CPython does this w_locals = space.w_None + w_modulename = space.newtext(modulename) w_globals = self.get_w_globals() if w_flag is None: w_obj = space.call_function(w_import, w_modulename, w_globals, @@ -1076,7 +1078,7 @@ raise try: w_pkgname = space.getattr( - w_module, space.newunicode(u'__name__')) + w_module, space.newtext('__name__')) w_fullname = space.newunicode(u'%s.%s' % (space.unicode_w(w_pkgname), space.unicode_w(w_name))) return space.getitem(space.sys.get('modules'), w_fullname) diff --git a/pypy/module/__builtin__/descriptor.py b/pypy/module/__builtin__/descriptor.py --- a/pypy/module/__builtin__/descriptor.py +++ b/pypy/module/__builtin__/descriptor.py @@ -46,7 +46,7 @@ return space.call_function(w_selftype, self.w_starttype, w_obj) def getattribute(self, space, w_name): - name = space.str_w(w_name) + name = space.text_w(w_name) # only use a special logic for bound super objects and not for # getting the __class__ of the super object itself. if self.w_objtype is not None and name != '__class__': diff --git a/pypy/module/_codecs/interp_codecs.py b/pypy/module/_codecs/interp_codecs.py --- a/pypy/module/_codecs/interp_codecs.py +++ b/pypy/module/_codecs/interp_codecs.py @@ -535,7 +535,7 @@ if w_encoding is None: encoding = space.sys.defaultencoding else: - encoding = space.str_w(w_encoding) + encoding = space.text_w(w_encoding) w_encoder = space.getitem(lookup_codec(space, encoding), space.newint(0)) return _call_codec(space, w_encoder, w_obj, "encoding", encoding, errors) @@ -558,7 +558,7 @@ if w_encoding is None: encoding = space.sys.defaultencoding else: - encoding = space.str_w(w_encoding) + encoding = space.text_w(w_encoding) w_decoder = space.getitem(lookup_codec(space, encoding), space.newint(1)) return _call_codec(space, w_decoder, w_obj, "decoding", encoding, errors) diff --git a/pypy/module/_locale/interp_locale.py b/pypy/module/_locale/interp_locale.py --- a/pypy/module/_locale/interp_locale.py +++ b/pypy/module/_locale/interp_locale.py @@ -26,7 +26,7 @@ if space.is_none(w_locale): locale = None else: - locale = space.str_w(w_locale) + locale = space.text_w(w_locale) try: result = rlocale.setlocale(category, locale) except rlocale.LocaleError as e: @@ -183,7 +183,7 @@ finally: rffi.free_charp(msg_c) else: - domain = space.str_w(w_domain) + domain = space.text_w(w_domain) domain_c = rffi.str2charp(domain) msg_c = rffi.str2charp(msg) try: @@ -218,7 +218,7 @@ finally: rffi.free_charp(msg_c) else: - domain = space.str_w(w_domain) + domain = space.text_w(w_domain) domain_c = rffi.str2charp(domain) msg_c = rffi.str2charp(msg) try: @@ -246,7 +246,7 @@ result = _textdomain(domain) result = rffi.charp2str(result) else: - domain = space.str_w(w_domain) + domain = space.text_w(w_domain) domain_c = rffi.str2charp(domain) try: result = _textdomain(domain_c) @@ -276,7 +276,7 @@ finally: rffi.free_charp(domain_c) else: - dir = space.str_w(w_dir) + dir = space.text_w(w_dir) domain_c = rffi.str2charp(domain) dir_c = rffi.str2charp(dir) try: @@ -307,7 +307,7 @@ finally: rffi.free_charp(domain_c) else: - codeset = space.str_w(w_codeset) + codeset = space.text_w(w_codeset) domain_c = rffi.str2charp(domain) codeset_c = rffi.str2charp(codeset) try: diff --git a/pypy/module/_lsprof/interp_lsprof.py b/pypy/module/_lsprof/interp_lsprof.py --- a/pypy/module/_lsprof/interp_lsprof.py +++ b/pypy/module/_lsprof/interp_lsprof.py @@ -49,11 +49,11 @@ return self.w_calls def repr(self, space): - frame_repr = space.str_w(space.repr(self.frame)) + frame_repr = space.text_w(space.repr(self.frame)) if not self.w_calls: calls_repr = "None" else: - calls_repr = space.str_w(space.repr(self.w_calls)) + calls_repr = space.text_w(space.repr(self.w_calls)) return space.newtext('("%s", %d, %d, %f, %f, %s)' % ( frame_repr, self.callcount, self.reccallcount, self.tt, self.it, calls_repr)) @@ -85,7 +85,7 @@ self.tt = tt def repr(self, space): - frame_repr = space.str_w(space.repr(self.frame)) + frame_repr = space.text_w(space.repr(self.frame)) return space.newtext('("%s", %d, %d, %f, %f)' % ( frame_repr, self.callcount, self.reccallcount, self.tt, self.it)) @@ -235,7 +235,7 @@ # This class should not be seen at app-level, but is useful to # contain a (w_func, w_type) pair returned by prepare_spec(). # Turning this pair into a string cannot be done eagerly in - # an @elidable function because of space.str_w(), but it can + # an @elidable function because of space.text_w(), but it can # be done lazily when we really want it. _immutable_fields_ = ['w_func', 'w_type'] @@ -253,7 +253,7 @@ s = create_spec_for_object(space, self.w_type) else: s = create_spec_for_method(space, self.w_func, self.w_type) - self.w_string = space.newtext(s) + self.w_string = space.newunicode(s) return self.w_string W_DelayedBuiltinStr.typedef = TypeDef( diff --git a/pypy/module/_minimal_curses/interp_curses.py b/pypy/module/_minimal_curses/interp_curses.py --- a/pypy/module/_minimal_curses/interp_curses.py +++ b/pypy/module/_minimal_curses/interp_curses.py @@ -51,7 +51,7 @@ if space.is_none(w_termname): _curses_setupterm_null(fd) else: - _curses_setupterm(space.str_w(w_termname), fd) + _curses_setupterm(space.text_w(w_termname), fd) except curses_error as e: raise convert_error(space, e) diff --git a/pypy/module/_multibytecodec/interp_incremental.py b/pypy/module/_multibytecodec/interp_incremental.py --- a/pypy/module/_multibytecodec/interp_incremental.py +++ b/pypy/module/_multibytecodec/interp_incremental.py @@ -33,7 +33,7 @@ return space.newtext(self.errors) def fset_errors(self, space, w_errors): - self.errors = space.str_w(w_errors) + self.errors = space.text_w(w_errors) class MultibyteIncrementalDecoder(MultibyteIncrementalBase): diff --git a/pypy/module/exceptions/interp_exceptions.py b/pypy/module/exceptions/interp_exceptions.py --- a/pypy/module/exceptions/interp_exceptions.py +++ b/pypy/module/exceptions/interp_exceptions.py @@ -786,7 +786,7 @@ args_w = [self.args_w[0], w_tuple] args_repr = space.unicode_w(space.repr(space.newtuple(args_w))) clsname = self.getclass(space).getname(space) - return space.newtext(clsname + args_repr) + return space.newunicode(clsname + args_repr) else: return W_Exception.descr_repr(self, space) diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py --- a/pypy/module/imp/importing.py +++ b/pypy/module/imp/importing.py @@ -380,7 +380,7 @@ module object. """ log_pyverbose(space, 1, "import %s # compiled from %s\n" % - (space.str_w(w_modulename), cpathname)) + (space.text_w(w_modulename), cpathname)) if magic != get_pyc_magic(space): raise oefmt(space.w_ImportError, "Bad magic number in %s", cpathname) diff --git a/pypy/module/imp/interp_imp.py b/pypy/module/imp/interp_imp.py --- a/pypy/module/imp/interp_imp.py +++ b/pypy/module/imp/interp_imp.py @@ -51,7 +51,7 @@ w_modulename = space.getattr(w_spec, space.newtext("name")) w_path = space.getattr(w_spec, space.newtext("origin")) filename = space.fsencode_w(w_path) - importing.load_c_extension(space, filename, space.str_w(w_modulename)) + importing.load_c_extension(space, filename, space.text_w(w_modulename)) return importing.check_sys_modules(space, w_modulename) def create_builtin(space, w_spec): diff --git a/pypy/module/itertools/interp_itertools.py b/pypy/module/itertools/interp_itertools.py --- a/pypy/module/itertools/interp_itertools.py +++ b/pypy/module/itertools/interp_itertools.py @@ -27,11 +27,11 @@ def repr_w(self): space = self.space - c = space.str_w(space.repr(self.w_c)) + c = space.text_w(space.repr(self.w_c)) if self.single_argument(): s = 'count(%s)' % (c,) else: - step = space.str_w(space.repr(self.w_step)) + step = space.text_w(space.repr(self.w_step)) s = 'count(%s, %s)' % (c, step) return self.space.newtext(s) @@ -107,7 +107,7 @@ return self.space.newint(self.count) def repr_w(self): - objrepr = self.space.str_w(self.space.repr(self.w_obj)) + objrepr = self.space.text_w(self.space.repr(self.w_obj)) if self.counting: s = 'repeat(%s, %d)' % (objrepr, self.count) else: diff --git a/pypy/module/marshal/interp_marshal.py b/pypy/module/marshal/interp_marshal.py --- a/pypy/module/marshal/interp_marshal.py +++ b/pypy/module/marshal/interp_marshal.py @@ -87,7 +87,7 @@ def read(self, n): space = self.space w_ret = space.call_function(self.func, space.newint(n)) - ret = space.str_w(w_ret) + ret = space.bytes_w(w_ret) if len(ret) < n: self.raise_eof() if len(ret) > n: diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py --- a/pypy/module/posix/interp_posix.py +++ b/pypy/module/posix/interp_posix.py @@ -1954,7 +1954,7 @@ # XXX slightly non-nice, reuses the sysconf of the underlying os module if space.isinstance_w(w_name, space.w_unicode): try: - num = namespace[space.str_w(w_name)] + num = namespace[space.text_w(w_name)] except KeyError: raise oefmt(space.w_ValueError, "unrecognized configuration name") else: diff --git a/pypy/module/pyexpat/__init__.py b/pypy/module/pyexpat/__init__.py --- a/pypy/module/pyexpat/__init__.py +++ b/pypy/module/pyexpat/__init__.py @@ -36,7 +36,7 @@ space = self.space for name in interp_pyexpat.xml_model_list: value = getattr(interp_pyexpat, name) - space.setattr(self, space.newtext(name), space.newtext(value)) + space.setattr(self, space.newtext(name), space.wrap(value)) class Module(MixedModule): "Python wrapper for Expat parser." diff --git a/pypy/module/pyexpat/interp_pyexpat.py b/pypy/module/pyexpat/interp_pyexpat.py --- a/pypy/module/pyexpat/interp_pyexpat.py +++ b/pypy/module/pyexpat/interp_pyexpat.py @@ -679,12 +679,12 @@ if space.is_w(w_context, space.w_None): context = None else: - context = space.str_w(w_context) + context = space.text_w(w_context) if space.is_none(w_encoding): encoding = None else: - encoding = space.str_w(w_encoding) + encoding = space.text_w(w_encoding) xmlparser = XML_ExternalEntityParserCreate( self.itself, context, encoding) @@ -816,8 +816,8 @@ Return a new XML parser object.""" if space.is_none(w_encoding): encoding = None - elif space.isinstance_w(w_encoding, space.w_unicode): - encoding = space.str_w(w_encoding) + elif space.isinstance_w(w_encoding, space.w_text): + encoding = space.text_w(w_encoding) else: raise oefmt(space.w_TypeError, "ParserCreate() argument 1 must be str or None, not %T", @@ -825,8 +825,8 @@ if space.is_none(w_namespace_separator): namespace_separator = 0 - elif space.isinstance_w(w_namespace_separator, space.w_unicode): - separator = space.str_w(w_namespace_separator) + elif space.isinstance_w(w_namespace_separator, space.w_text): + separator = space.text_w(w_namespace_separator) if len(separator) == 0: namespace_separator = 0 elif len(separator) == 1: diff --git a/pypy/module/zipimport/interp_zipimport.py b/pypy/module/zipimport/interp_zipimport.py --- a/pypy/module/zipimport/interp_zipimport.py +++ b/pypy/module/zipimport/interp_zipimport.py @@ -299,7 +299,7 @@ for compiled, _, ext in ENUMERATE_EXTS: if self.have_modulefile(space, filename + ext): w_source = self.get_data(space, filename + ext) - source = space.str_w(w_source) + source = space.bytes_w(w_source) if compiled: magic = importing._get_long(source[:4]) timestamp = importing._get_long(source[4:8]) diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py --- a/pypy/objspace/descroperation.py +++ b/pypy/objspace/descroperation.py @@ -65,7 +65,7 @@ def get_attribute_name(space, w_obj, w_name): try: - return space.str_w(w_name) + return space.text_w(w_name) except OperationError as e: if e.match(space, space.w_UnicodeEncodeError): raiseattrerror(space, w_obj, w_name) diff --git a/pypy/objspace/std/callmethod.py b/pypy/objspace/std/callmethod.py --- a/pypy/objspace/std/callmethod.py +++ b/pypy/objspace/std/callmethod.py @@ -44,7 +44,7 @@ w_type = space.type(w_obj) if w_type.has_object_getattribute(): - name = space.str_w(w_name) + name = space.text_w(w_name) # bit of a mess to use these internal functions, but it allows the # mapdict caching below to work without an additional lookup version_tag = w_type.version_tag() @@ -106,7 +106,7 @@ break w_value = f.popvalue() w_key = f.popvalue() - key = f.space.str_w(w_key) + key = f.space.text_w(w_key) keywords[n_kwargs] = key keywords_w[n_kwargs] = w_value diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py --- a/pypy/objspace/std/mapdict.py +++ b/pypy/objspace/std/mapdict.py @@ -740,7 +740,7 @@ def getitem(self, w_dict, w_key): space = self.space w_lookup_type = space.type(w_key) - if space.is_w(w_lookup_type, space.w_unicode): + if space.is_w(w_lookup_type, space.w_text): return self.getitem_str(w_dict, space.text_w(w_key)) elif _never_equal_to_string(space, w_lookup_type): return None @@ -759,7 +759,7 @@ def setitem(self, w_dict, w_key, w_value): space = self.space - if space.is_w(space.type(w_key), space.w_unicode): + if space.is_w(space.type(w_key), space.w_text): self.setitem_str(w_dict, self.space.text_w(w_key), w_value) else: self.switch_to_object_strategy(w_dict) @@ -767,7 +767,7 @@ def setdefault(self, w_dict, w_key, w_default): space = self.space - if space.is_w(space.type(w_key), space.w_unicode): + if space.is_w(space.type(w_key), space.w_text): key = space.text_w(w_key) w_result = self.getitem_str(w_dict, key) if w_result is not None: @@ -782,7 +782,7 @@ space = self.space w_key_type = space.type(w_key) w_obj = self.unerase(w_dict.dstorage) - if space.is_w(w_key_type, space.w_unicode): + if space.is_w(w_key_type, space.w_text): key = self.space.text_w(w_key) flag = w_obj.deldictvalue(space, key) if not flag: @@ -983,7 +983,7 @@ return space._handle_getattribute(w_descr, w_obj, w_name) version_tag = w_type.version_tag() if version_tag is not None: - name = space.str_w(w_name) + name = space.text_w(w_name) # We need to care for obscure cases in which the w_descr is # a MutableCell, which may change without changing the version_tag _, w_descr = w_type._pure_lookup_where_with_method_cache( diff --git a/pypy/objspace/std/sliceobject.py b/pypy/objspace/std/sliceobject.py --- a/pypy/objspace/std/sliceobject.py +++ b/pypy/objspace/std/sliceobject.py @@ -106,9 +106,9 @@ def descr_repr(self, space): return space.newtext("slice(%s, %s, %s)" % ( - space.str_w(space.repr(self.w_start)), - space.str_w(space.repr(self.w_stop)), - space.str_w(space.repr(self.w_step)))) + space.text_w(space.repr(self.w_start)), + space.text_w(space.repr(self.w_stop)), + space.text_w(space.repr(self.w_step)))) def descr__reduce__(self, space): from pypy.objspace.std.sliceobject import W_SliceObject diff --git a/pypy/objspace/std/test/test_dictmultiobject.py b/pypy/objspace/std/test/test_dictmultiobject.py --- a/pypy/objspace/std/test/test_dictmultiobject.py +++ b/pypy/objspace/std/test/test_dictmultiobject.py @@ -1230,6 +1230,7 @@ return unicode return type(w_obj) w_unicode = unicode + w_text = unicode w_bytes = str def text_w(self, u): diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py --- a/pypy/objspace/std/typeobject.py +++ b/pypy/objspace/std/typeobject.py @@ -663,7 +663,7 @@ return space.newtext("<class '%s'>" % (self.name,)) def descr_getattribute(self, space, w_name): - name = space.str_w(w_name) + name = space.text_w(w_name) w_descr = space.lookup(self, name) if w_descr is not None: if space.is_data_descr(w_descr): @@ -724,14 +724,14 @@ return space.call_function(newfunc, w_winner, w_name, w_bases, w_dict) w_typetype = w_winner - name = space.str_w(w_name) + name = space.text_w(w_name) assert isinstance(name, str) if '\x00' in name: raise oefmt(space.w_ValueError, "type name must not contain null characters") dict_w = {} dictkeys_w = space.listview(w_dict) for w_key in dictkeys_w: - key = space.str_w(w_key) + key = space.text_w(w_key) dict_w[key] = space.getitem(w_dict, w_key) w_type = space.allocate_instance(W_TypeObject, w_typetype) W_TypeObject.__init__(w_type, space, name, bases_w or [space.w_object], @@ -789,7 +789,7 @@ raise oefmt(space.w_TypeError, "can only assign string to %N.__name__, not '%T'", w_type, w_value) - name = space.str_w(w_value) + name = space.text_w(w_value) if '\x00' in name: raise oefmt(space.w_ValueError, "type name must not contain null characters") w_type.name = name @@ -1151,7 +1151,7 @@ slot_name = mangle(slot_name, w_self.name) if slot_name not in w_self.dict_w: # Force interning of slot names. - slot_name = space.str_w(space.new_interned_str(slot_name)) + slot_name = space.text_w(space.new_interned_str(slot_name)) # in cpython it is ignored less, but we probably don't care member = Member(index_next_extra_slot, slot_name, w_self) w_self.dict_w[slot_name] = member _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit