[pypy-commit] pypy py3.5: Remove some more space.str_w and 'str0'
arigo
pypy.commits at gmail.com
Wed Feb 22 08:58:44 EST 2017
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r90295:fbd3692ba3cd
Date: 2017-02-22 14:31 +0100
http://bitbucket.org/pypy/pypy/changeset/fbd3692ba3cd/
Log: Remove some more space.str_w and 'str0'
diff --git a/pypy/interpreter/astcompiler/fstring.py b/pypy/interpreter/astcompiler/fstring.py
--- a/pypy/interpreter/astcompiler/fstring.py
+++ b/pypy/interpreter/astcompiler/fstring.py
@@ -362,7 +362,7 @@
raise
# Unicode/ValueError in literal: turn into SyntaxError
e.normalize_exception(space)
- errmsg = space.str_w(space.str(e.get_w_value(space)))
+ errmsg = space.text_w(space.str(e.get_w_value(space)))
raise astbuilder.error('(%s) %s' % (kind, errmsg), atom_node)
if not fmode and len(joined_pieces) == 1: # <= the common path
diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py
--- a/pypy/interpreter/generator.py
+++ b/pypy/interpreter/generator.py
@@ -300,7 +300,7 @@
def descr_set__name__(self, space, w_name):
if space.isinstance_w(w_name, space.w_unicode):
- self._name = space.str_w(w_name)
+ self._name = space.text_w(w_name)
else:
raise oefmt(space.w_TypeError,
"__name__ must be set to a string object")
diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -376,7 +376,7 @@
@unwrap_spec(argcount=int, kwonlyargcount=int, nlocals=int, stacksize=int, flags=int,
codestring='bytes',
- filename='str0', name='text', firstlineno=int,
+ filename='fsencode', name='text', firstlineno=int,
lnotab='bytes', magic=int)
def descr_code__new__(space, w_subtype,
argcount, kwonlyargcount, nlocals, stacksize, flags,
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
@@ -365,7 +365,7 @@
obj = space.realunicode_w(space.getattr(w_exc, space.newtext('object')))
start = space.int_w(space.getattr(w_exc, space.newtext('start')))
w_end = space.getattr(w_exc, space.newtext('end'))
- encoding = space.str_w(space.getattr(w_exc, space.newtext('encoding')))
+ encoding = space.text_w(space.getattr(w_exc, space.newtext('encoding')))
bytelength, code = get_standard_encoding(encoding)
if code == ENC_UNKNOWN:
# Not supported, fail with original exception
@@ -403,7 +403,7 @@
elif space.isinstance_w(w_exc, space.w_UnicodeDecodeError):
start = space.int_w(space.getattr(w_exc, space.newtext('start')))
obj = space.bytes_w(space.getattr(w_exc, space.newtext('object')))
- encoding = space.str_w(space.getattr(w_exc, space.newtext('encoding')))
+ encoding = space.text_w(space.getattr(w_exc, space.newtext('encoding')))
bytelength, code = get_standard_encoding(encoding)
ch = 0
# Try decoding a single surrogate character. If there are more,
diff --git a/pypy/module/_multiprocessing/interp_semaphore.py b/pypy/module/_multiprocessing/interp_semaphore.py
--- a/pypy/module/_multiprocessing/interp_semaphore.py
+++ b/pypy/module/_multiprocessing/interp_semaphore.py
@@ -215,7 +215,7 @@
return rffi.cast(SEM_T, space.int_w(w_handle))
def semaphore_unlink(space, w_name):
- name = space.str_w(w_name)
+ name = space.text_w(w_name)
try:
sem_unlink(name)
except OSError as e:
@@ -550,7 +550,7 @@
def _finalize_(self):
delete_semaphore(self.handle)
- at unwrap_spec(kind=int, value=int, maxvalue=int, name=str, unlink=int)
+ at unwrap_spec(kind=int, value=int, maxvalue=int, name='text', unlink=int)
def descr_new(space, w_subtype, kind, value, maxvalue, name, unlink):
if kind != RECURSIVE_MUTEX and kind != SEMAPHORE:
raise oefmt(space.w_ValueError, "unrecognized kind")
diff --git a/pypy/module/_rawffi/alt/interp_struct.py b/pypy/module/_rawffi/alt/interp_struct.py
--- a/pypy/module/_rawffi/alt/interp_struct.py
+++ b/pypy/module/_rawffi/alt/interp_struct.py
@@ -102,7 +102,7 @@
return W__StructInstance(self, allocate=False, autofree=True, rawmem=rawmem)
def get_type_and_offset_for_field(self, space, w_name):
- name = space.str_w(w_name)
+ name = space.text_w(w_name)
try:
return self._get_type_and_offset_for_field(space, name)
except KeyError:
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
@@ -132,7 +132,7 @@
Get host and port for a sockaddr."""
try:
- host = space.str_w((space.getitem(w_sockaddr, space.newint(0))))
+ host = space.text_w((space.getitem(w_sockaddr, space.newint(0))))
port = str(space.int_w(space.getitem(w_sockaddr, space.newint(1))))
lst = rsocket.getaddrinfo(host, port, rsocket.AF_UNSPEC,
rsocket.SOCK_DGRAM, 0,
@@ -310,7 +310,7 @@
elif space.isinstance_w(w_port, space.w_bytes):
port = space.bytes_w(w_port)
elif space.isinstance_w(w_port, space.w_unicode):
- port = space.str_w(w_port)
+ port = space.text_w(w_port)
else:
raise oefmt(space.w_TypeError,
"getaddrinfo() argument 2 must be integer or string")
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
@@ -160,8 +160,8 @@
if space.isinstance_w(w_string, space.w_unicode):
unicodestr = space.unicode_w(w_string)
length = len(unicodestr)
- elif space.isinstance_w(w_string, space.w_str):
- string = space.str_w(w_string)
+ elif space.isinstance_w(w_string, space.w_bytes):
+ string = space.bytes_w(w_string)
length = len(string)
else:
buf = space.readbuf_w(w_string)
diff --git a/pypy/module/array/reconstructor.py b/pypy/module/array/reconstructor.py
--- a/pypy/module/array/reconstructor.py
+++ b/pypy/module/array/reconstructor.py
@@ -71,7 +71,7 @@
MACHINE_FORMAT_CODE_MAX = max(format_descriptors)
- at unwrap_spec(typecode=str, mformat_code=int)
+ at unwrap_spec(typecode='text', mformat_code=int)
def array_reconstructor(space, w_cls, typecode, mformat_code, w_items):
# Fast path: machine format code corresponds to the
# platform-independent typecode.
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
@@ -135,7 +135,7 @@
consts=space.fixedview(w_consts),
names=unwrap_list_of_texts(space, w_names),
varnames=unwrap_list_of_texts(space, w_varnames),
- filename=space.str0_w(w_filename),
+ filename=space.fsencode_w(w_filename),
name=space.text_w(w_funcname),
firstlineno=rffi.cast(lltype.Signed, firstlineno),
lnotab=space.bytes_w(w_lnotab),
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
@@ -52,7 +52,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),
+ view.c_buf = rffi.cast(rffi.VOIDP, rffi.str2charp(space.bytes_w(w_s),
track_allocation=False))
rffi.setintfield(view, 'c_readonly', 1)
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
@@ -358,7 +358,7 @@
space.realunicode_w(w_object)
space.int_w(w_start)
space.int_w(w_end)
- space.str_w(w_reason)
+ space.text_w(w_reason)
# assign attributes
self.w_object = w_object
self.w_start = w_start
@@ -908,11 +908,11 @@
w_bytes = space.newbytes(space.bufferstr_w(w_object))
else:
w_bytes = w_object
- space.str_w(w_encoding)
+ space.text_w(w_encoding)
space.bytes_w(w_bytes)
space.int_w(w_start)
space.int_w(w_end)
- space.str_w(w_reason)
+ space.text_w(w_reason)
# assign attributes
self.w_encoding = w_encoding
self.w_object = w_bytes
@@ -1001,11 +1001,11 @@
def descr_init(self, space, w_encoding, w_object, w_start, w_end, w_reason):
# typechecking
- space.str_w(w_encoding)
+ space.text_w(w_encoding)
space.realunicode_w(w_object)
space.int_w(w_start)
space.int_w(w_end)
- space.str_w(w_reason)
+ space.text_w(w_reason)
# assign attributes
self.w_encoding = w_encoding
self.w_object = w_object
diff --git a/pypy/module/parser/pyparser.py b/pypy/module/parser/pyparser.py
--- a/pypy/module/parser/pyparser.py
+++ b/pypy/module/parser/pyparser.py
@@ -49,7 +49,7 @@
return self._build_app_tree(space, self.tree, space.newlist,
line_info, col_info)
- @unwrap_spec(filename='str0')
+ @unwrap_spec(filename='fsencode')
def descr_compile(self, space, filename="<syntax-tree>"):
info = pyparse.CompileInfo(filename, self.mode)
try:
diff --git a/pypy/module/posix/interp_scandir.py b/pypy/module/posix/interp_scandir.py
--- a/pypy/module/posix/interp_scandir.py
+++ b/pypy/module/posix/interp_scandir.py
@@ -19,7 +19,7 @@
if space.is_none(w_path):
w_path = space.newunicode(u".")
if space.isinstance_w(w_path, space.w_bytes):
- path_bytes = space.str0_w(w_path)
+ path_bytes = space.bytes0_w(w_path)
result_is_bytes = True
else:
path_bytes = space.fsencode_w(w_path)
diff --git a/pypy/module/struct/interp_struct.py b/pypy/module/struct/interp_struct.py
--- a/pypy/module/struct/interp_struct.py
+++ b/pypy/module/struct/interp_struct.py
@@ -208,7 +208,7 @@
__length_hint__=interp2app(W_UnpackIter.descr_length_hint)
)
- at unwrap_spec(format=str)
+ at unwrap_spec(format='text')
def iter_unpack(space, format, w_buffer):
w_struct = W_Struct(space, format)
return W_UnpackIter(space, w_struct, w_buffer)
diff --git a/pypy/module/sys/interp_encoding.py b/pypy/module/sys/interp_encoding.py
--- a/pypy/module/sys/interp_encoding.py
+++ b/pypy/module/sys/interp_encoding.py
@@ -34,7 +34,7 @@
space.newtext(loc_codeset))
if space.is_true(w_res):
w_name = space.getattr(w_res, space.newtext('name'))
- encoding = space.str_w(w_name)
+ encoding = space.text_w(w_name)
finally:
rlocale.setlocale(rlocale.LC_CTYPE, oldlocale)
except rlocale.LocaleError:
diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -487,8 +487,8 @@
self.std_wp(s)
return
if not do_unicode:
- if space.isinstance_w(w_value, space.w_str):
- s = space.str_w(w_value)
+ if space.isinstance_w(w_value, space.w_bytes):
+ s = space.bytes_w(w_value)
elif space.isinstance_w(w_value, space.w_bytearray):
s = w_value.buffer_w(space, 0).as_str()
else:
diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py
--- a/pypy/objspace/std/intobject.py
+++ b/pypy/objspace/std/intobject.py
@@ -58,7 +58,7 @@
return space.newlong_from_rbigint(b)
@staticmethod
- @unwrap_spec(byteorder=str, signed=bool)
+ @unwrap_spec(byteorder='text', signed=bool)
def descr_from_bytes(space, w_inttype, w_obj, byteorder, signed=False):
"""int.from_bytes(bytes, byteorder, *, signed=False) -> int
@@ -97,7 +97,7 @@
w_obj = space.call_function(w_inttype, w_obj)
return w_obj
- @unwrap_spec(nbytes=int, byteorder=str, signed=bool)
+ @unwrap_spec(nbytes=int, byteorder='text', signed=bool)
def descr_to_bytes(self, space, nbytes, byteorder, signed=False):
"""to_bytes(...)
int.to_bytes(length, byteorder, *, signed=False) -> bytes
diff --git a/pypy/objspace/std/memoryobject.py b/pypy/objspace/std/memoryobject.py
--- a/pypy/objspace/std/memoryobject.py
+++ b/pypy/objspace/std/memoryobject.py
@@ -529,7 +529,7 @@
raise oefmt(space.w_TypeError,
"memoryview: format argument must be a string")
- fmt = space.str_w(w_format)
+ fmt = space.text_w(w_format)
buf = self.buf
ndim = 1
More information about the pypy-commit
mailing list