Author: Carl Friedrich Bolz <[email protected]>
Branch: space-newtext
Changeset: r88790:d05e3f3498f3
Date: 2016-12-01 13:31 +0100
http://bitbucket.org/pypy/pypy/changeset/d05e3f3498f3/
Log: replace more w_str and str_w instances
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
@@ -15,7 +15,7 @@
if self.filename is None:
w_filename = space.w_None
else:
- w_filename = space.newtext(self.filename)
+ w_filename = space.newtext_or_none(self.filename)
if self.text is None:
w_text = space.w_None
else:
diff --git a/pypy/module/__pypy__/interp_debug.py
b/pypy/module/__pypy__/interp_debug.py
--- a/pypy/module/__pypy__/interp_debug.py
+++ b/pypy/module/__pypy__/interp_debug.py
@@ -9,7 +9,7 @@
@jit.dont_look_inside
def debug_print(space, args_w):
- parts = [space.str_w(space.str(w_item)) for w_item in args_w]
+ parts = [space.text_w(space.str(w_item)) for w_item in args_w]
debug.debug_print(' '.join(parts))
@jit.dont_look_inside
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
@@ -183,8 +183,8 @@
jit.promote(space.int_w(w_obj))
elif space.is_w(space.type(w_obj), space.w_float):
jit.promote(space.float_w(w_obj))
- elif space.is_w(space.type(w_obj), space.w_str):
- jit.promote_string(space.str_w(w_obj))
+ elif space.is_w(space.type(w_obj), space.w_bytes):
+ jit.promote_string(space.bytes_w(w_obj))
elif space.is_w(space.type(w_obj), space.w_unicode):
raise oefmt(space.w_TypeError, "promoting unicode unsupported")
else:
diff --git a/pypy/module/_io/interp_bufferedio.py
b/pypy/module/_io/interp_bufferedio.py
--- a/pypy/module/_io/interp_bufferedio.py
+++ b/pypy/module/_io/interp_bufferedio.py
@@ -91,7 +91,7 @@
if not space.isinstance_w(w_data, space.w_str):
raise oefmt(space.w_TypeError, "read() should return bytes")
- data = space.str_w(w_data)
+ data = space.bytes_w(w_data)
rwbuffer.setslice(0, data)
return space.newint(len(data))
@@ -225,7 +225,7 @@
raise
return space.newtext("<%s>" % (typename,))
else:
- name_repr = space.str_w(space.repr(w_name))
+ name_repr = space.text_w(space.repr(w_name))
return space.newtext("<%s name=%s>" % (typename, name_repr))
# ______________________________________________
diff --git a/pypy/module/_io/interp_fileio.py b/pypy/module/_io/interp_fileio.py
--- a/pypy/module/_io/interp_fileio.py
+++ b/pypy/module/_io/interp_fileio.py
@@ -326,7 +326,7 @@
w_repr = space.repr(self.w_name)
return space.newtext(
"<_io.FileIO name=%s mode='%s'>" % (
- space.str_w(w_repr), self._mode()))
+ space.text_w(w_repr), self._mode()))
# ______________________________________________
diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -375,9 +375,8 @@
else:
newline = space.unicode_w(w_newline)
if newline and newline not in (u'\n', u'\r\n', u'\r'):
- r = space.str_w(space.repr(w_newline))
raise oefmt(space.w_ValueError,
- "illegal newline value: %s", r)
+ "illegal newline value: %R", w_newline)
self.line_buffering = line_buffering
@@ -398,7 +397,7 @@
# build the decoder object
if space.is_true(space.call_method(w_buffer, "readable")):
w_codec = interp_codecs.lookup_codec(space,
- space.str_w(self.w_encoding))
+ space.text_w(self.w_encoding))
self.w_decoder = space.call_method(w_codec,
"incrementaldecoder", w_errors)
if self.readuniversal:
@@ -409,7 +408,7 @@
# build the encoder object
if space.is_true(space.call_method(w_buffer, "writable")):
w_codec = interp_codecs.lookup_codec(space,
- space.str_w(self.w_encoding))
+ space.text_w(self.w_encoding))
self.w_encoder = space.call_method(w_codec,
"incrementalencoder", w_errors)
@@ -875,9 +874,8 @@
whence)
if space.is_true(space.lt(w_pos, space.newint(0))):
- r = space.str_w(space.repr(w_pos))
raise oefmt(space.w_ValueError,
- "negative seek position %s", r)
+ "negative seek position %R", w_pos)
space.call_method(self, "flush")
@@ -984,7 +982,7 @@
w_state = space.call_method(self.w_decoder, "getstate")
w_dec_buffer, w_flags = space.unpackiterable(w_state, 2)
- dec_buffer_len = len(space.str_w(w_dec_buffer))
+ dec_buffer_len = space.len_w(w_dec_buffer)
if dec_buffer_len == 0 and chars_decoded <= chars_to_skip:
# Decoder buffer is empty, so this is a safe start point.
diff --git a/pypy/module/_rawffi/alt/interp_funcptr.py
b/pypy/module/_rawffi/alt/interp_funcptr.py
--- a/pypy/module/_rawffi/alt/interp_funcptr.py
+++ b/pypy/module/_rawffi/alt/interp_funcptr.py
@@ -20,9 +20,9 @@
def _getfunc(space, CDLL, w_name, w_argtypes, w_restype):
argtypes_w, argtypes, w_restype, restype = unpack_argtypes(
space, w_argtypes, w_restype)
- if (space.isinstance_w(w_name, space.w_str) or
+ if (space.isinstance_w(w_name, space.w_bytes) or
space.isinstance_w(w_name, space.w_unicode)):
- name = space.str_w(w_name)
+ name = space.text_w(w_name)
try:
func = CDLL.cdll.getpointer(name, argtypes, restype,
flags = CDLL.flags)
@@ -54,7 +54,7 @@
else:
@unwrap_spec(name=str)
def _getfunc(space, CDLL, w_name, w_argtypes, w_restype):
- name = space.str_w(w_name)
+ name = space.text_w(w_name)
argtypes_w, argtypes, w_restype, restype = unpack_argtypes(
space, w_argtypes, w_restype)
try:
diff --git a/pypy/module/_rawffi/alt/type_converter.py
b/pypy/module/_rawffi/alt/type_converter.py
--- a/pypy/module/_rawffi/alt/type_converter.py
+++ b/pypy/module/_rawffi/alt/type_converter.py
@@ -79,11 +79,11 @@
def maybe_handle_char_or_unichar_p(self, w_ffitype, w_obj):
w_type = jit.promote(self.space.type(w_obj))
- if w_ffitype.is_char_p() and w_type is self.space.w_str:
+ if w_ffitype.is_char_p() and w_type is self.space.w_bytes:
strval = self.space.str_w(w_obj)
self.handle_char_p(w_ffitype, w_obj, strval)
return True
- elif w_ffitype.is_unichar_p() and (w_type is self.space.w_str or
+ elif w_ffitype.is_unichar_p() and (w_type is self.space.w_bytes or
w_type is self.space.w_unicode):
unicodeval = self.space.unicode_w(w_obj)
self.handle_unichar_p(w_ffitype, w_obj, unicodeval)
diff --git a/pypy/module/_rawffi/array.py b/pypy/module/_rawffi/array.py
--- a/pypy/module/_rawffi/array.py
+++ b/pypy/module/_rawffi/array.py
@@ -185,7 +185,7 @@
def setslice(self, space, w_slice, w_value):
start, stop = self.decodeslice(space, w_slice)
- value = space.str_w(w_value)
+ value = space.bytes_w(w_value)
if start + len(value) != stop:
raise oefmt(space.w_ValueError, "cannot resize array")
ll_buffer = self.ll_buffer
diff --git a/pypy/module/_rawffi/callback.py b/pypy/module/_rawffi/callback.py
--- a/pypy/module/_rawffi/callback.py
+++ b/pypy/module/_rawffi/callback.py
@@ -79,7 +79,7 @@
self.argtypes = unpack_argshapes(space, w_args)
ffiargs = [tp.get_basic_ffi_type() for tp in self.argtypes]
if not space.is_w(w_result, space.w_None):
- self.result = space.str_w(w_result)
+ self.result = space.text_w(w_result)
ffiresult = letter2tp(space, self.result).get_basic_ffi_type()
else:
self.result = None
diff --git a/pypy/module/_rawffi/interp_rawffi.py
b/pypy/module/_rawffi/interp_rawffi.py
--- a/pypy/module/_rawffi/interp_rawffi.py
+++ b/pypy/module/_rawffi/interp_rawffi.py
@@ -100,7 +100,7 @@
def unpack_simple_shape(space, w_shape):
# 'w_shape' must be either a letter or a tuple (struct, 1).
if space.isinstance_w(w_shape, space.w_str):
- letter = space.str_w(w_shape)
+ letter = space.text_w(w_shape)
return letter2tp(space, letter)
else:
w_shapetype, w_length = space.fixedview(w_shape, expected_length=2)
@@ -110,8 +110,8 @@
def unpack_shape_with_length(space, w_shape):
# Allow 'w_shape' to be a letter or any (shape, number).
# The result is always a W_Array.
- if space.isinstance_w(w_shape, space.w_str):
- letter = space.str_w(w_shape)
+ if space.isinstance_w(w_shape, space.w_text):
+ letter = space.text_w(w_shape)
return letter2tp(space, letter)
else:
w_shapetype, w_length = space.fixedview(w_shape, expected_length=2)
@@ -186,8 +186,8 @@
else:
ffi_restype = ffi_type_void
- if space.isinstance_w(w_name, space.w_str):
- name = space.str_w(w_name)
+ if space.isinstance_w(w_name, space.w_text):
+ name = space.text_w(w_name)
try:
ptr = self.cdll.getrawpointer(name, ffi_argtypes, ffi_restype,
@@ -408,7 +408,7 @@
push_func(add_arg, argdesc, rffi.cast(rffi.LONGDOUBLE,
space.float_w(w_arg)))
elif letter == "c":
- s = space.str_w(w_arg)
+ s = space.bytes_w(w_arg)
if len(s) != 1:
raise oefmt(space.w_TypeError,
"Expected string of length one as character")
diff --git a/pypy/module/_rawffi/structure.py b/pypy/module/_rawffi/structure.py
--- a/pypy/module/_rawffi/structure.py
+++ b/pypy/module/_rawffi/structure.py
@@ -37,7 +37,7 @@
"Expected list of 2- or 3-size tuples")
try:
- name = space.str_w(l_w[0])
+ name = space.text_w(l_w[0])
except OperationError:
raise oefmt(space.w_TypeError,
"structure field name must be string not %T", l_w[0])
diff --git a/pypy/module/_socket/interp_func.py
b/pypy/module/_socket/interp_func.py
--- a/pypy/module/_socket/interp_func.py
+++ b/pypy/module/_socket/interp_func.py
@@ -77,7 +77,7 @@
if space.is_w(w_proto, space.w_None):
proto = None
else:
- proto = space.str_w(w_proto)
+ proto = space.text_w(w_proto)
try:
port = rsocket.getservbyname(name, proto)
except SocketError as e:
@@ -95,7 +95,7 @@
if space.is_w(w_proto, space.w_None):
proto = None
else:
- proto = space.str_w(w_proto)
+ proto = space.text_w(w_proto)
if port < 0 or port > 0xffff:
raise oefmt(space.w_ValueError, "getservbyport: port must be 0-65535.")
diff --git a/pypy/module/_socket/interp_socket.py
b/pypy/module/_socket/interp_socket.py
--- a/pypy/module/_socket/interp_socket.py
+++ b/pypy/module/_socket/interp_socket.py
@@ -83,7 +83,7 @@
def addr_from_object(family, fd, space, w_address):
if family == rsocket.AF_INET:
w_host, w_port = space.unpackiterable(w_address, 2)
- host = space.str_w(w_host)
+ host = space.text_w(w_host)
port = space.int_w(w_port)
port = make_ushort_port(space, port)
return rsocket.INETAddress(host, port)
@@ -93,7 +93,7 @@
raise oefmt(space.w_TypeError,
"AF_INET6 address must be a tuple of length 2 "
"to 4, not %d", len(pieces_w))
- host = space.str_w(pieces_w[0])
+ host = space.text_w(pieces_w[0])
port = space.int_w(pieces_w[1])
port = make_ushort_port(space, port)
if len(pieces_w) > 2: flowinfo = space.int_w(pieces_w[2])
@@ -103,7 +103,7 @@
flowinfo = make_unsigned_flowinfo(space, flowinfo)
return rsocket.INET6Address(host, port, flowinfo, scope_id)
if rsocket.HAS_AF_UNIX and family == rsocket.AF_UNIX:
- return rsocket.UNIXAddress(space.str_w(w_address))
+ return rsocket.UNIXAddress(space.text_w(w_address))
if rsocket.HAS_AF_NETLINK and family == rsocket.AF_NETLINK:
w_pid, w_groups = space.unpackiterable(w_address, 2)
return rsocket.NETLINKAddress(space.uint_w(w_pid),
space.uint_w(w_groups))
@@ -113,14 +113,14 @@
raise oefmt(space.w_TypeError,
"AF_PACKET address must be a tuple of length 2 "
"to 5, not %d", len(pieces_w))
- ifname = space.str_w(pieces_w[0])
+ ifname = space.text_w(pieces_w[0])
ifindex = rsocket.PacketAddress.get_ifindex_from_ifname(fd, ifname)
protocol = space.int_w(pieces_w[1])
if len(pieces_w) > 2: pkttype = space.int_w(pieces_w[2])
else: pkttype = 0
if len(pieces_w) > 3: hatype = space.int_w(pieces_w[3])
else: hatype = 0
- if len(pieces_w) > 4: haddr = space.str_w(pieces_w[4])
+ if len(pieces_w) > 4: haddr = space.text_w(pieces_w[4])
else: haddr = ""
if len(haddr) > 8:
raise oefmt(space.w_ValueError,
@@ -144,7 +144,7 @@
# XXX Hack to seperate rpython and pypy
def ipaddr_from_object(space, w_sockaddr):
- host = space.str_w(space.getitem(w_sockaddr, space.newint(0)))
+ host = space.text_w(space.getitem(w_sockaddr, space.newint(0)))
addr = rsocket.makeipaddr(host)
fill_from_object(addr, space, w_sockaddr)
return addr
@@ -165,7 +165,7 @@
is_open = self.sock.fd >= 0
if is_open and self.space.sys.track_resources:
w_repr = self.space.repr(self)
- str_repr = self.space.str_w(w_repr)
+ str_repr = self.space.text_w(w_repr)
w_msg = self.space.newtext("WARNING: unclosed " + str_repr)
self.space.resource_warning(w_msg, self.w_tb)
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
@@ -116,8 +116,8 @@
endpos = len(unicodestr)
return rsre_core.UnicodeMatchContext(self.code, unicodestr,
pos, endpos, self.flags)
- elif space.isinstance_w(w_string, space.w_str):
- str = space.str_w(w_string)
+ elif space.isinstance_w(w_string, space.w_bytes):
+ str = space.bytes_w(w_string)
if pos > len(str):
pos = len(str)
if endpos > len(str):
diff --git a/pypy/module/bz2/interp_bz2.py b/pypy/module/bz2/interp_bz2.py
--- a/pypy/module/bz2/interp_bz2.py
+++ b/pypy/module/bz2/interp_bz2.py
@@ -413,7 +413,7 @@
raise oefmt(self.space.w_EOFError,
"compressed file ended before the logical "
"end-of-the-stream was detected")
- result = self.space.str_w(w_result)
+ result = self.space.bytes_w(w_result)
self.readlength += len(result)
else:
result = ""
@@ -443,7 +443,7 @@
self.finished = True
return ""
raise
- self.buffer = self.space.str_w(w_read)
+ self.buffer = self.space.bytes_w(w_read)
self.pos = 0
if len(self.buffer) - self.pos >= n:
pos = self.pos
@@ -478,11 +478,11 @@
self.writtenlength = 0
def close1(self, closefileno):
- self.stream.write(self.space.str_w(self.compressor.flush()))
+ self.stream.write(self.space.bytes_w(self.compressor.flush()))
self.stream.close1(closefileno)
def write(self, data):
- self.stream.write(self.space.str_w(self.compressor.compress(data)))
+ self.stream.write(self.space.bytes_w(self.compressor.compress(data)))
self.writtenlength += len(data)
def tell(self):
diff --git a/pypy/module/cStringIO/interp_stringio.py
b/pypy/module/cStringIO/interp_stringio.py
--- a/pypy/module/cStringIO/interp_stringio.py
+++ b/pypy/module/cStringIO/interp_stringio.py
@@ -178,7 +178,7 @@
if not e.match(space, space.w_StopIteration):
raise
break # done
- self.write(space.str_w(w_line))
+ self.write(space.text_w(w_line))
# ____________________________________________________________
diff --git a/pypy/module/cpyext/bytesobject.py
b/pypy/module/cpyext/bytesobject.py
--- a/pypy/module/cpyext/bytesobject.py
+++ b/pypy/module/cpyext/bytesobject.py
@@ -79,7 +79,7 @@
c_ob_sval must not be modified.
"""
py_str = rffi.cast(PyBytesObject, py_obj)
- s = space.str_w(w_obj)
+ s = space.bytes_w(w_obj)
if py_str.c_ob_size < len(s):
raise oefmt(space.w_ValueError,
"bytes_attach called on object with ob_size %d but trying to store
%d",
diff --git a/pypy/module/cpyext/classobject.py
b/pypy/module/cpyext/classobject.py
--- a/pypy/module/cpyext/classobject.py
+++ b/pypy/module/cpyext/classobject.py
@@ -30,7 +30,7 @@
@cpython_api([PyObject, PyObject], PyObject, error=CANNOT_FAIL)
def _PyInstance_Lookup(space, w_instance, w_name):
- name = space.str_w(w_name)
+ name = space.text_w(w_name)
assert isinstance(w_instance, W_InstanceObject)
w_result = w_instance.getdictvalue(space, name)
if w_result is not None:
diff --git a/pypy/module/cpyext/funcobject.py b/pypy/module/cpyext/funcobject.py
--- a/pypy/module/cpyext/funcobject.py
+++ b/pypy/module/cpyext/funcobject.py
@@ -118,8 +118,8 @@
assert isinstance(w_method, Method)
return w_method.w_class # borrowed ref
-def unwrap_list_of_strings(space, w_list):
- return [space.str_w(w_item) for w_item in space.fixedview(w_list)]
+def unwrap_list_of_texts(space, w_list):
+ return [space.text_w(w_item) for w_item in space.fixedview(w_list)]
@cpython_api([rffi.INT_real, rffi.INT_real, rffi.INT_real, rffi.INT_real,
PyObject, PyObject, PyObject, PyObject, PyObject, PyObject,
@@ -136,16 +136,16 @@
nlocals=rffi.cast(lltype.Signed, nlocals),
stacksize=rffi.cast(lltype.Signed, stacksize),
flags=rffi.cast(lltype.Signed, flags),
- code=space.str_w(w_code),
+ code=space.bytes_w(w_code),
consts=space.fixedview(w_consts),
- names=unwrap_list_of_strings(space, w_names),
- varnames=unwrap_list_of_strings(space, w_varnames),
- filename=space.str_w(w_filename),
- name=space.str_w(w_funcname),
+ names=unwrap_list_of_texts(space, w_names),
+ varnames=unwrap_list_of_texts(space, w_varnames),
+ filename=space.text_w(w_filename),
+ name=space.text_w(w_funcname),
firstlineno=rffi.cast(lltype.Signed, firstlineno),
- lnotab=space.str_w(w_lnotab),
- freevars=unwrap_list_of_strings(space, w_freevars),
- cellvars=unwrap_list_of_strings(space, w_cellvars))
+ lnotab=space.bytes_w(w_lnotab),
+ freevars=unwrap_list_of_texts(space, w_freevars),
+ cellvars=unwrap_list_of_texts(space, w_cellvars))
@cpython_api([CONST_STRING, CONST_STRING, rffi.INT_real], PyCodeObject)
def PyCode_NewEmpty(space, filename, funcname, firstlineno):
diff --git a/pypy/module/cpyext/memoryobject.py
b/pypy/module/cpyext/memoryobject.py
--- a/pypy/module/cpyext/memoryobject.py
+++ b/pypy/module/cpyext/memoryobject.py
@@ -170,7 +170,7 @@
except ValueError:
w_s = w_obj.descr_tobytes(space)
view.c_obj = make_ref(space, w_s)
- view.c_buf = rffi.cast(rffi.VOIDP, rffi.str2charp(space.str_w(w_s),
track_allocation=False))
+ view.c_buf = rffi.cast(rffi.VOIDP, rffi.str2charp(space.text_w(w_s),
track_allocation=False))
rffi.setintfield(view, 'c_readonly', 1)
isstr = True
return view
diff --git a/pypy/module/cpyext/ndarrayobject.py
b/pypy/module/cpyext/ndarrayobject.py
--- a/pypy/module/cpyext/ndarrayobject.py
+++ b/pypy/module/cpyext/ndarrayobject.py
@@ -173,7 +173,7 @@
0, NULL);
except OperationError as e:
if e.match(space, space.w_NotImplementedError):
- errstr = space.str_w(e.get_w_value(space))
+ errstr = space.text_w(e.get_w_value(space))
raise oefmt(space.w_NotImplementedError,
"_PyArray_FromObject %s", errstr[16:])
raise
diff --git a/pypy/module/cpyext/object.py b/pypy/module/cpyext/object.py
--- a/pypy/module/cpyext/object.py
+++ b/pypy/module/cpyext/object.py
@@ -471,7 +471,7 @@
w_str = space.repr(w_obj)
count = space.len_w(w_str)
- data = space.str_w(w_str)
+ data = space.text_w(w_str)
with rffi.scoped_nonmovingbuffer(data) as buf:
fwrite(buf, 1, count, fp)
return 0
diff --git a/pypy/module/cpyext/pyerrors.py b/pypy/module/cpyext/pyerrors.py
--- a/pypy/module/cpyext/pyerrors.py
+++ b/pypy/module/cpyext/pyerrors.py
@@ -338,7 +338,7 @@
state = space.fromcache(State)
operror = state.clear_exception()
if operror:
- operror.write_unraisable(space, space.str_w(space.repr(w_where)))
+ operror.write_unraisable(space, space.text_w(space.repr(w_where)))
@cpython_api([], lltype.Void)
def PyErr_SetInterrupt(space):
diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py
--- a/pypy/module/cpyext/slotdefs.py
+++ b/pypy/module/cpyext/slotdefs.py
@@ -139,7 +139,7 @@
func_target = rffi.cast(getattrfunc, func)
check_num_args(space, w_args, 1)
args_w = space.fixedview(w_args)
- name_ptr = rffi.str2charp(space.str_w(args_w[0]))
+ name_ptr = rffi.str2charp(space.text_w(args_w[0]))
try:
return generic_cpy_call(space, func_target, w_self, name_ptr)
finally:
@@ -636,10 +636,11 @@
view.c_buf = rffi.cast(rffi.VOIDP, buf.get_raw_address())
view.c_obj = make_ref(space, w_obj)
except ValueError:
- w_s = space.newbytes(buf.as_str())
+ s = buf.as_str()
+ w_s = space.newbytes(s)
view.c_obj = make_ref(space, w_s)
view.c_buf = rffi.cast(rffi.VOIDP, rffi.str2charp(
- space.str_w(w_s), track_allocation=False))
+ s, track_allocation=False))
rffi.setintfield(view, 'c_readonly', 1)
ret = fill_Py_buffer(space, buf, view)
return ret
diff --git a/pypy/module/cpyext/state.py b/pypy/module/cpyext/state.py
--- a/pypy/module/cpyext/state.py
+++ b/pypy/module/cpyext/state.py
@@ -100,7 +100,7 @@
argv = space.sys.get('argv')
if space.len_w(argv):
argv0 = space.getitem(argv, space.newint(0))
- progname = space.str_w(argv0)
+ progname = space.text_w(argv0)
else:
progname = "pypy"
self.programname = rffi.str2charp(progname)
@@ -111,7 +111,7 @@
if not self.version:
space = self.space
w_version = space.sys.get('version')
- version = space.str_w(w_version)
+ version = space.text_w(w_version)
self.version = rffi.str2charp(version)
lltype.render_immortal(self.version)
return self.version
diff --git a/pypy/module/cpyext/structmember.py
b/pypy/module/cpyext/structmember.py
--- a/pypy/module/cpyext/structmember.py
+++ b/pypy/module/cpyext/structmember.py
@@ -115,7 +115,7 @@
return 0
if member_type == T_CHAR:
- str_value = space.str_w(w_value)
+ str_value = space.text_w(w_value)
if len(str_value) != 1:
raise oefmt(space.w_TypeError, "string of length 1 expected")
array = rffi.cast(rffi.CCHARP, addr)
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -947,7 +947,7 @@
if not space.isinstance_w(w_name, space.w_str):
return None
- name = space.str_w(w_name)
+ name = space.text_w(w_name)
w_obj = w_type.lookup(name)
# this assumes that w_obj is not dynamically created, but will stay alive
# until w_type is modified or dies. Assuming this, we return a borrowed
ref
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -502,11 +502,11 @@
@staticmethod
def _op_val(space, w_other, strict=None):
- if strict and not space.isinstance_w(w_other, space.w_str):
+ if strict and not space.isinstance_w(w_other, space.w_bytes):
raise oefmt(space.w_TypeError,
"%s arg must be None, str or unicode", strict)
try:
- return space.str_w(w_other)
+ return space.bytes_w(w_other)
except OperationError as e:
if not e.match(space, space.w_TypeError):
raise
@@ -569,7 +569,7 @@
# NB. the default value of w_object is really a *wrapped* empty string:
# there is gateway magic at work
w_obj = space.str(w_object)
- if space.is_w(w_stringtype, space.w_str):
+ if space.is_w(w_stringtype, space.w_bytes):
return w_obj # XXX might be reworked when space.str() typechecks
value = space.bytes_w(w_obj)
w_obj = space.allocate_instance(W_BytesObject, w_stringtype)
@@ -596,9 +596,9 @@
return newformat.format_method(space, self, __args__, is_unicode=False)
def descr__format__(self, space, w_format_spec):
- if not space.isinstance_w(w_format_spec, space.w_str):
+ if not space.isinstance_w(w_format_spec, space.w_bytes):
w_format_spec = space.str(w_format_spec)
- spec = space.str_w(w_format_spec)
+ spec = space.bytes_w(w_format_spec)
formatter = newformat.str_formatter(space, spec)
return formatter.format_string(self._value)
@@ -826,11 +826,11 @@
return self._StringMethods_descr_rpartition(space, w_sub)
def _join_return_one(self, space, w_obj):
- return (space.is_w(space.type(w_obj), space.w_str) or
+ return (space.is_w(space.type(w_obj), space.w_bytes) or
space.is_w(space.type(w_obj), space.w_unicode))
def _join_check_item(self, space, w_obj):
- if space.isinstance_w(w_obj, space.w_str):
+ if space.isinstance_w(w_obj, space.w_bytes):
return 0
if space.isinstance_w(w_obj, space.w_unicode):
return 2
@@ -851,12 +851,12 @@
def descr_formatter_parser(self, space):
from pypy.objspace.std.newformat import str_template_formatter
- tformat = str_template_formatter(space, space.str_w(self))
+ tformat = str_template_formatter(space, space.bytes_w(self))
return tformat.formatter_parser()
def descr_formatter_field_name_split(self, space):
from pypy.objspace.std.newformat import str_template_formatter
- tformat = str_template_formatter(space, space.str_w(self))
+ tformat = str_template_formatter(space, space.bytes_w(self))
return tformat.formatter_field_name_split()
diff --git a/pypy/objspace/std/newformat.py b/pypy/objspace/std/newformat.py
--- a/pypy/objspace/std/newformat.py
+++ b/pypy/objspace/std/newformat.py
@@ -352,7 +352,7 @@
if recursive:
spec = self._build_string(spec_start, end, level)
w_rendered = self.space.format(w_obj, self.wrap(spec))
- unwrapper = "unicode_w" if self.is_unicode else "str_w"
+ unwrapper = "unicode_w" if self.is_unicode else "bytes_w"
to_interp = getattr(self.space, unwrapper)
return to_interp(w_rendered)
@@ -382,7 +382,7 @@
space.unicode_w(w_string))
return space.newunicode(template.build(args))
else:
- template = str_template_formatter(space, space.str_w(w_string))
+ template = str_template_formatter(space, space.bytes_w(w_string))
return space.newbytes(template.build(args))
@@ -1175,5 +1175,5 @@
formatter = unicode_formatter(space, space.unicode_w(w_format_spec))
return getattr(formatter, meth)(*args)
else:
- formatter = str_formatter(space, space.str_w(w_format_spec))
+ formatter = str_formatter(space, space.bytes_w(w_format_spec))
return getattr(formatter, meth)(*args)
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
@@ -77,7 +77,7 @@
return space.newint(uid)
def str_w(self, space):
- return space.str_w(space.str(self))
+ return space.text_w(space.str(self))
def unicode_w(self, space):
return self._value
@@ -450,8 +450,8 @@
def _get_encoding_and_errors(space, w_encoding, w_errors):
- encoding = None if w_encoding is None else space.str_w(w_encoding)
- errors = None if w_errors is None else space.str_w(w_errors)
+ encoding = None if w_encoding is None else space.text_w(w_encoding)
+ errors = None if w_errors is None else space.text_w(w_errors)
return encoding, errors
@@ -569,7 +569,7 @@
encoding = getdefaultencoding(space)
if encoding != 'ascii':
return unicode_from_encoded_object(space, w_str, encoding, "strict")
- s = space.str_w(w_str)
+ s = space.bytes_w(w_str)
try:
return W_UnicodeObject(s.decode("ascii"))
except UnicodeDecodeError:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit