[pypy-commit] pypy default: Remove space.str_w() and space.str0_w() in RPython code.
arigo
pypy.commits at gmail.com
Wed Feb 22 06:10:56 EST 2017
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r90286:a87a8bb34ecd
Date: 2017-02-22 12:09 +0100
http://bitbucket.org/pypy/pypy/changeset/a87a8bb34ecd/
Log: Remove space.str_w() and space.str0_w() in RPython code. Remove
``str`` as an unwrap_spec argument.
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1617,12 +1617,12 @@
unwrapped RPython bytestring."""
return w_obj.str_w(self)
- #@not_rpython BACKCOMPAT: should be replaced with bytes_w or text_w
+ @not_rpython # tests only; should be replaced with bytes_w or text_w
def str_w(self, w_obj):
"""For tests only."""
return self.bytes_w(w_obj)
- #@not_rpython BACKCOMPAT
+ @not_rpython # tests only; should be replaced with bytes0_w or text0_w
def str0_w(self, w_obj):
return self.bytes0_w(w_obj)
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -148,9 +148,6 @@
def visit_str_or_None(self, el, app_sig):
self.checked_space_method(el, app_sig)
- def visit_str0(self, el, app_sig):
- self.checked_space_method(el, app_sig)
-
def visit_bytes(self, el, app_sig):
self.checked_space_method(el, app_sig)
@@ -292,9 +289,6 @@
def visit_str_or_None(self, typ):
self.run_args.append("space.str_or_None_w(%s)" % (self.scopenext(),))
- def visit_str0(self, typ):
- self.run_args.append("space.str0_w(%s)" % (self.scopenext(),))
-
def visit_bytes(self, typ):
self.run_args.append("space.bytes_w(%s)" % (self.scopenext(),))
@@ -457,9 +451,6 @@
def visit_str_or_None(self, typ):
self.unwrap.append("space.str_or_None_w(%s)" % (self.nextarg(),))
- def visit_str0(self, typ):
- self.unwrap.append("space.str0_w(%s)" % (self.nextarg(),))
-
def visit_bytes(self, typ):
self.unwrap.append("space.bytes_w(%s)" % (self.nextarg(),))
@@ -606,6 +597,8 @@
"the name of an argument of the following "
"function" % (name,))
+ assert str not in unwrap_spec # use 'text' or 'bytes' instead of str
+
return unwrap_spec
diff --git a/pypy/interpreter/mixedmodule.py b/pypy/interpreter/mixedmodule.py
--- a/pypy/interpreter/mixedmodule.py
+++ b/pypy/interpreter/mixedmodule.py
@@ -48,7 +48,7 @@
space.call_method(self.w_dict, 'update', self.w_initialdict)
for w_submodule in self.submodules_w:
- name = space.str0_w(w_submodule.w_name)
+ name = space.text0_w(w_submodule.w_name)
space.setitem(self.w_dict, space.newtext(name.split(".")[-1]), w_submodule)
space.getbuiltinmodule(name)
diff --git a/pypy/interpreter/module.py b/pypy/interpreter/module.py
--- a/pypy/interpreter/module.py
+++ b/pypy/interpreter/module.py
@@ -42,7 +42,7 @@
def install(self):
"""NOT_RPYTHON: installs this module into space.builtin_modules"""
- modulename = self.space.str0_w(self.w_name)
+ modulename = self.space.text0_w(self.w_name)
self.space.builtin_modules[modulename] = self
def setup_after_space_initialization(self):
diff --git a/pypy/interpreter/test/test_gateway.py b/pypy/interpreter/test/test_gateway.py
--- a/pypy/interpreter/test/test_gateway.py
+++ b/pypy/interpreter/test/test_gateway.py
@@ -377,7 +377,7 @@
return space.wrap(s0+s1)
app_g3_ss = gateway.interp2app_temp(g3_ss,
unwrap_spec=[gateway.ObjSpace,
- str, 'str_or_None'])
+ 'text', 'str_or_None'])
w_app_g3_ss = space.wrap(app_g3_ss)
assert self.space.eq_w(
space.call(w_app_g3_ss,
@@ -512,7 +512,7 @@
app_g3_s = gateway.interp2app_temp(g3_id,
unwrap_spec=[gateway.ObjSpace,
- str])
+ 'text'])
w_app_g3_s = space.wrap(app_g3_s)
assert space.eq_w(space.call_function(w_app_g3_s,w("foo")),w("foo"))
raises(gateway.OperationError,space.call_function,w_app_g3_s,w(None))
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
@@ -3,7 +3,7 @@
from pypy.interpreter.gateway import unwrap_spec
- at unwrap_spec(name='str0')
+ at unwrap_spec(name='text0')
def real_getenv(space, name):
"""Get an OS environment value skipping Python cache"""
return space.newtext_or_none(os.environ.get(name))
diff --git a/pypy/module/_cffi_backend/test/test_recompiler.py b/pypy/module/_cffi_backend/test/test_recompiler.py
--- a/pypy/module/_cffi_backend/test/test_recompiler.py
+++ b/pypy/module/_cffi_backend/test/test_recompiler.py
@@ -6,7 +6,7 @@
import pypy.module.cpyext.api # side-effect of pre-importing it
- at unwrap_spec(cdef=str, module_name=str, source=str, packed=int)
+ at unwrap_spec(cdef='text', module_name='text', source='text', packed=int)
def prepare(space, cdef, module_name, source, w_includes=None,
w_extra_source=None, w_min_version=None, packed=False):
try:
diff --git a/pypy/module/_multiprocessing/interp_win32.py b/pypy/module/_multiprocessing/interp_win32.py
--- a/pypy/module/_multiprocessing/interp_win32.py
+++ b/pypy/module/_multiprocessing/interp_win32.py
@@ -114,7 +114,7 @@
# __________________________________________________________
# functions for the "win32" namespace
- at unwrap_spec(name=str, openmode=r_uint, pipemode=r_uint, maxinstances=r_uint,
+ at unwrap_spec(name='text', openmode=r_uint, pipemode=r_uint, maxinstances=r_uint,
outputsize=r_uint, inputsize=r_uint, timeout=r_uint)
def CreateNamedPipe(space, name, openmode, pipemode, maxinstances,
outputsize, inputsize, timeout, w_security):
@@ -161,13 +161,13 @@
lltype.free(state, flavor='raw')
lltype.free(statep, flavor='raw')
- at unwrap_spec(name=str, timeout=r_uint)
+ at unwrap_spec(name='text', timeout=r_uint)
def WaitNamedPipe(space, name, timeout):
# Careful: zero means "default value specified by CreateNamedPipe()"
if not _WaitNamedPipe(name, timeout):
raise wrap_windowserror(space, rwin32.lastSavedWindowsError())
- at unwrap_spec(filename=str, access=r_uint, share=r_uint,
+ at unwrap_spec(filename='fsencode', access=r_uint, share=r_uint,
disposition=r_uint, flags=r_uint)
def CreateFile(space, filename, access, share, w_security,
disposition, flags, w_templatefile):
diff --git a/pypy/module/_rawffi/alt/test/test_struct.py b/pypy/module/_rawffi/alt/test/test_struct.py
--- a/pypy/module/_rawffi/alt/test/test_struct.py
+++ b/pypy/module/_rawffi/alt/test/test_struct.py
@@ -43,7 +43,7 @@
def setup_class(cls):
BaseAppTestFFI.setup_class.im_func(cls)
- @unwrap_spec(addr=int, typename=str, length=int)
+ @unwrap_spec(addr=int, typename='text', length=int)
def read_raw_mem(space, addr, typename, length):
import ctypes
addr = ctypes.cast(addr, ctypes.c_void_p)
diff --git a/pypy/module/_ssl/interp_win32.py b/pypy/module/_ssl/interp_win32.py
--- a/pypy/module/_ssl/interp_win32.py
+++ b/pypy/module/_ssl/interp_win32.py
@@ -99,7 +99,7 @@
usage.c_rgpszUsageIdentifier[i]))
return space.newset(result_w)
- at unwrap_spec(store_name=str)
+ at unwrap_spec(store_name='text')
def enum_certificates_w(space, store_name):
"""enum_certificates(store_name) -> []
@@ -142,7 +142,7 @@
return space.newlist(result_w)
- at unwrap_spec(store_name=str)
+ at unwrap_spec(store_name='text')
def enum_crls_w(space, store_name):
"""enum_crls(store_name) -> []
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
@@ -328,7 +328,7 @@
raise oefmt(space.w_ValueError, "cannot open in read-write mode")
if basemode == "a":
raise oefmt(space.w_ValueError, "cannot append to bz2 file")
- stream = open_path_helper(space.str0_w(w_path), os_flags, False)
+ stream = open_path_helper(space.fsencode_w(w_path), os_flags, False)
if reading:
bz2stream = ReadBZ2Filter(space, stream, buffering)
buffering = 0 # by construction, the ReadBZ2Filter acts like
diff --git a/pypy/module/bz2/test/test_bz2_file.py b/pypy/module/bz2/test/test_bz2_file.py
--- a/pypy/module/bz2/test/test_bz2_file.py
+++ b/pypy/module/bz2/test/test_bz2_file.py
@@ -28,7 +28,7 @@
data = DATA[:100]
f.write(data, 'wb')
- @unwrap_spec(data=str)
+ @unwrap_spec(data='bytes')
def decompress(space, data):
import popen2
import bz2
diff --git a/pypy/module/cppyy/test/test_crossing.py b/pypy/module/cppyy/test/test_crossing.py
--- a/pypy/module/cppyy/test/test_crossing.py
+++ b/pypy/module/cppyy/test/test_crossing.py
@@ -78,7 +78,7 @@
import ctypes, cppyy""") # prevents leak-checking complaints on ctypes' statics
def setup_method(self, func):
- @unwrap_spec(name=str, init=str, body=str)
+ @unwrap_spec(name='text', init='text', body='text')
def create_cdll(space, name, init, body):
# the following is loosely from test_cpyext.py import_module; it
# is copied here to be able to tweak the call to
diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -287,7 +287,7 @@
if self.runappdirect:
return
- @unwrap_spec(name=str)
+ @unwrap_spec(name='text')
def compile_module(space, name,
w_source_files=None,
w_source_strings=None):
@@ -313,7 +313,7 @@
return space.wrap(pydname)
- @unwrap_spec(name=str, init='str_or_None', body=str,
+ @unwrap_spec(name='text', init='str_or_None', body='text',
filename='str_or_None', PY_SSIZE_T_CLEAN=bool)
def import_module(space, name, init=None, body='',
filename=None, w_include_dirs=None,
@@ -325,12 +325,12 @@
return w_result
- @unwrap_spec(mod=str, name=str)
+ @unwrap_spec(mod='text', name='text')
def load_module(space, mod, name):
return self.sys_info.load_module(mod, name)
- @unwrap_spec(modname=str, prologue=str,
- more_init=str, PY_SSIZE_T_CLEAN=bool)
+ @unwrap_spec(modname='text', prologue='text',
+ more_init='text', PY_SSIZE_T_CLEAN=bool)
def import_extension(space, modname, w_functions, prologue="",
w_include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False):
functions = space.unwrap(w_functions)
diff --git a/pypy/module/gc/interp_gc.py b/pypy/module/gc/interp_gc.py
--- a/pypy/module/gc/interp_gc.py
+++ b/pypy/module/gc/interp_gc.py
@@ -79,7 +79,7 @@
# ____________________________________________________________
- at unwrap_spec(filename='str0')
+ at unwrap_spec(filename='fsencode')
def dump_heap_stats(space, filename):
tb = rgc._heap_stats()
if not tb:
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
@@ -491,7 +491,7 @@
def __init__(self, space):
pass
- @unwrap_spec(path='str0')
+ @unwrap_spec(path='fsencode')
def descr_init(self, space, path):
if not path:
raise oefmt(space.w_ImportError, "empty pathname")
@@ -570,7 +570,7 @@
if w_loader:
return FindInfo.fromLoader(w_loader)
- path = space.str0_w(w_pathitem)
+ path = space.fsencode_w(w_pathitem)
filepart = os.path.join(path, partname)
log_pyverbose(space, 2, "# trying %s\n" % (filepart,))
if os.path.isdir(filepart) and case_ok(filepart):
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
@@ -78,7 +78,7 @@
def load_module(space, w_name, w_file, w_filename, w_info):
w_suffix, w_filemode, w_modtype = space.unpackiterable(w_info, 3)
- filename = space.str0_w(w_filename)
+ filename = space.fsencode_w(w_filename)
filemode = space.text_w(w_filemode)
if space.is_w(w_file, space.w_None):
stream = None
@@ -95,7 +95,7 @@
space, w_name, find_info, reuse=True)
def load_source(space, w_modulename, w_filename, w_file=None):
- filename = space.str0_w(w_filename)
+ filename = space.fsencode_w(w_filename)
stream = get_file(space, w_file, filename, 'U')
@@ -109,7 +109,7 @@
stream.close()
return w_mod
- at unwrap_spec(filename='str0', check_afterwards=int)
+ at unwrap_spec(filename='fsencode', check_afterwards=int)
def _run_compiled_module(space, w_modulename, filename, w_file, w_module,
check_afterwards=False):
# the function 'imp._run_compiled_module' is a pypy-only extension
@@ -125,14 +125,14 @@
stream.close()
return w_mod
- at unwrap_spec(filename='str0')
+ at unwrap_spec(filename='fsencode')
def load_compiled(space, w_modulename, filename, w_file=None):
w_mod = Module(space, w_modulename)
importing._prepare_module(space, w_mod, filename, None)
return _run_compiled_module(space, w_modulename, filename, w_file, w_mod,
check_afterwards=True)
- at unwrap_spec(filename='text')
+ at unwrap_spec(filename='fsencode')
def load_dynamic(space, w_modulename, filename, w_file=None):
if not importing.has_so_extension(space):
raise oefmt(space.w_ImportError, "Not implemented")
diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py
--- a/pypy/module/sys/initpath.py
+++ b/pypy/module/sys/initpath.py
@@ -147,17 +147,17 @@
return None
- at unwrap_spec(executable='str0')
+ at unwrap_spec(executable='fsencode')
def pypy_find_executable(space, executable):
return space.newtext(find_executable(executable))
- at unwrap_spec(filename='str0')
+ at unwrap_spec(filename='fsencode')
def pypy_resolvedirof(space, filename):
return space.newtext(resolvedirof(filename))
- at unwrap_spec(executable='str0')
+ at unwrap_spec(executable='fsencode')
def pypy_find_stdlib(space, executable):
path, prefix = None, None
if executable != '*':
diff --git a/pypy/module/test_lib_pypy/test_md5_extra.py b/pypy/module/test_lib_pypy/test_md5_extra.py
--- a/pypy/module/test_lib_pypy/test_md5_extra.py
+++ b/pypy/module/test_lib_pypy/test_md5_extra.py
@@ -94,7 +94,7 @@
# interp2app doesn't work in appdirect mode
cls.w_compare_host = staticmethod(compare_host)
else:
- compare_host.unwrap_spec = [str, str, str]
+ compare_host.unwrap_spec = ['bytes', 'bytes', 'text']
cls.w_compare_host = space.wrap(gateway.interp2app(compare_host))
def w_compare(self, message):
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
@@ -350,7 +350,7 @@
space = self.space
return space.newtext(self.filename)
- at unwrap_spec(name='str0')
+ at unwrap_spec(name='text0')
def descr_new_zipimporter(space, w_type, name):
ok = False
parts_ends = [i for i in range(0, len(name))
diff --git a/pypy/objspace/std/test/test_mapdict.py b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -899,7 +899,7 @@
successes = entry.success_counter
globalfailures = INVALID_CACHE_ENTRY.failure_counter
return space.wrap((failures, successes, globalfailures))
- check.unwrap_spec = [gateway.ObjSpace, gateway.W_Root, str]
+ check.unwrap_spec = [gateway.ObjSpace, gateway.W_Root, 'text']
cls.w_check = cls.space.wrap(gateway.interp2app(check))
def test_simple(self):
More information about the pypy-commit
mailing list