Author: Carl Friedrich Bolz <[email protected]>
Branch: space-newtext
Changeset: r88733:7608447652cb
Date: 2016-11-29 10:51 +0100
http://bitbucket.org/pypy/pypy/changeset/7608447652cb/
Log: remove wrap calls in the objspace implementation itself
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -786,10 +786,12 @@
return self.is_true(self.contains(w_container, w_item))
def setitem_str(self, w_obj, key, w_value):
- return self.setitem(w_obj, self.wrap(key), w_value)
+ # key is a "text" (ie str in python2 and unicode in python3)
+ return self.setitem(w_obj, self.newtext(key), w_value)
def finditem_str(self, w_obj, key):
- return self.finditem(w_obj, self.wrap(key))
+ # key is a "text" (ie str in python2 and unicode in python3)
+ return self.finditem(w_obj, self.newtext(key))
def finditem(self, w_obj, w_key):
try:
@@ -832,11 +834,12 @@
return w_s1
def new_interned_str(self, s):
+ # returns a "text" (ie str in python2 and unicode in python3)
if not we_are_translated():
assert type(s) is str
w_s1 = self.interned_strings.get(s)
if w_s1 is None:
- w_s1 = self.wrap(s)
+ w_s1 = self.newbytes(s)
self.interned_strings.set(s, w_s1)
return w_s1
@@ -1174,7 +1177,7 @@
return w_res
def call_method(self, w_obj, methname, *arg_w):
- w_meth = self.getattr(w_obj, self.wrap(methname))
+ w_meth = self.getattr(w_obj, self.newbytes(methname))
return self.call_function(w_meth, *arg_w)
def raise_key_error(self, w_key):
@@ -1183,7 +1186,7 @@
def lookup(self, w_obj, name):
w_type = self.type(w_obj)
- w_mro = self.getattr(w_type, self.wrap("__mro__"))
+ w_mro = self.getattr(w_type, self.newbytes("__mro__"))
for w_supertype in self.fixedview(w_mro):
w_value = w_supertype.getdictvalue(self, name)
if w_value is not None:
@@ -1204,7 +1207,7 @@
if self.is_oldstyle_instance(w_obj):
# ugly old style class special treatment, but well ...
try:
- self.getattr(w_obj, self.wrap("__call__"))
+ self.getattr(w_obj, self.newbytes("__call__"))
return self.w_True
except OperationError as e:
if not e.match(self, self.w_AttributeError):
@@ -1216,7 +1219,7 @@
def issequence_w(self, w_obj):
if self.is_oldstyle_instance(w_obj):
- return (self.findattr(w_obj, self.wrap('__getitem__')) is not None)
+ return (self.findattr(w_obj, self.newbytes('__getitem__')) is not
None)
flag = self.type(w_obj).flag_map_or_seq
if flag == 'M':
return False
@@ -1227,7 +1230,7 @@
def ismapping_w(self, w_obj):
if self.is_oldstyle_instance(w_obj):
- return (self.findattr(w_obj, self.wrap('__getitem__')) is not None)
+ return (self.findattr(w_obj, self.newbytes('__getitem__')) is not
None)
flag = self.type(w_obj).flag_map_or_seq
if flag == 'M':
return True
@@ -1305,15 +1308,15 @@
hidden_applevel=hidden_applevel)
if not isinstance(statement, PyCode):
raise TypeError('space.exec_(): expected a string, code or PyCode
object')
- w_key = self.wrap('__builtins__')
+ w_key = self.newbytes('__builtins__')
if not self.contains_w(w_globals, w_key):
- self.setitem(w_globals, w_key, self.wrap(self.builtin))
+ self.setitem(w_globals, w_key, self.builtin)
return statement.exec_code(self, w_globals, w_locals)
@specialize.arg(2)
def appexec(self, posargs_w, source):
""" return value from executing given source at applevel.
- EXPERIMENTAL. The source must look like
+ The source must look like
'''(x, y):
do_stuff...
return result
@@ -1417,7 +1420,7 @@
raise
if not w_exception:
# w_index should be a long object, but can't be sure of that
- if self.is_true(self.lt(w_index, self.wrap(0))):
+ if self.is_true(self.lt(w_index, self.newint(0))):
return -sys.maxint-1
else:
return sys.maxint
@@ -1780,7 +1783,7 @@
if (not self.isinstance_w(w_fd, self.w_int) and
not self.isinstance_w(w_fd, self.w_long)):
try:
- w_fileno = self.getattr(w_fd, self.wrap("fileno"))
+ w_fileno = self.getattr(w_fd, self.newbytes("fileno"))
except OperationError as e:
if e.match(self, self.w_AttributeError):
raise oefmt(self.w_TypeError,
@@ -1805,7 +1808,7 @@
return fd
def warn(self, w_msg, w_warningcls, stacklevel=2):
- self.appexec([w_msg, w_warningcls, self.wrap(stacklevel)],
+ self.appexec([w_msg, w_warningcls, self.newint(stacklevel)],
"""(msg, warningcls, stacklevel):
import _warnings
_warnings.warn(msg, warningcls, stacklevel=stacklevel)
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -536,7 +536,7 @@
if isinstance(w_slice, W_SliceObject):
a, b, c = w_slice.indices3(self, self.int_w(w_length))
return (a, b, c)
- w_indices = self.getattr(w_slice, self.wrap('indices'))
+ w_indices = self.getattr(w_slice, self.newbytes('indices'))
w_tup = self.call_function(w_indices, w_length)
l_w = self.unpackiterable(w_tup)
if not len(l_w) == 3:
@@ -629,7 +629,7 @@
not w_obj.user_overridden_class):
w_obj.setitem_str(key, w_value)
else:
- self.setitem(w_obj, self.wrap(key), w_value)
+ self.setitem(w_obj, self.newtext(key), w_value)
def getindex_w(self, w_obj, w_exception, objdescr=None):
if type(w_obj) is W_IntObject:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit