Author: Armin Rigo <[email protected]>
Branch: py3.5-newtext
Changeset: r90138:a13e864fa592
Date: 2017-02-15 08:41 +0100
http://bitbucket.org/pypy/pypy/changeset/a13e864fa592/
Log: hg merge 5f267995aab4 (keeping wrap and wrap_not_rpython separate)
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -783,9 +783,13 @@
return self.is_true(self.contains(w_container, w_item))
def setitem_str(self, w_obj, key, w_value):
+ # key is a "text", i.e. a byte string (in python3 it
+ # represents a utf-8-encoded unicode)
return self.setitem(w_obj, self.newtext(key), w_value)
def finditem_str(self, w_obj, key):
+ # key is a "text", i.e. a byte string (in python3 it
+ # represents a utf-8-encoded unicode)
return self.finditem(w_obj, self.newtext(key))
def finditem(self, w_obj, w_key):
@@ -829,13 +833,14 @@
return w_u1
def new_interned_str(self, s):
- """Assumes an identifier (utf-8 encoded str)"""
+ # Assumes an identifier (utf-8 encoded str)
+ # returns a "text" object (ie str in python2 and unicode in python3)
if not we_are_translated():
assert type(s) is str
u = s.decode('utf-8')
w_s1 = self.interned_strings.get(u)
if w_s1 is None:
- w_s1 = self.wrap(u)
+ w_s1 = self.newtext(u)
self.interned_strings.set(u, w_s1)
return w_s1
@@ -1291,7 +1296,7 @@
@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
diff --git a/pypy/module/cppyy/__init__.py b/pypy/module/cppyy/__init__.py
--- a/pypy/module/cppyy/__init__.py
+++ b/pypy/module/cppyy/__init__.py
@@ -40,4 +40,4 @@
from pypy.module.cppyy import capi
capi.verify_backend(space) # may raise ImportError
- space.call_method(space.wrap(self), '_init_pythonify')
+ space.call_method(self, '_init_pythonify')
diff --git a/pypy/module/cpyext/unicodeobject.py
b/pypy/module/cpyext/unicodeobject.py
--- a/pypy/module/cpyext/unicodeobject.py
+++ b/pypy/module/cpyext/unicodeobject.py
@@ -972,4 +972,5 @@
Unicode strings. CRLF is considered to be one line break. If
keepend is 0, the Line break characters are not included in the
resulting strings."""
- return space.call_method(w_str, "splitlines", space.newbool(bool(keepend)))
+ w_keepend = space.newbool(bool(rffi.cast(lltype.Signed, keepend)))
+ return space.call_method(w_str, "splitlines", w_keepend)
diff --git a/pypy/module/micronumpy/descriptor.py
b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -860,7 +860,7 @@
alignment = -1
format = dtype_from_spec(space, obj[0], alignment=alignment)
if len(obj) > 2:
- title = space.wrap(obj[2])
+ title = obj[2]
else:
title = space.w_None
allfields.append((fname_w, format, num, title))
@@ -874,7 +874,7 @@
else:
alignment = -1
for i in range(len(names)):
- aslist.append(space.newtuple([space.wrap(names[i]),
space.wrap(formats[i])]))
+ aslist.append(space.newtuple([names[i], formats[i]]))
return dtype_from_list(space, space.newlist(aslist), False, alignment,
offsets=offsets)
def dtype_from_dict(space, w_dict, alignment):
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
@@ -12,6 +12,7 @@
from rpython.rlib.debug import make_sure_not_resized
from rpython.rlib.rarithmetic import base_int, widen, is_valid_int
from rpython.rlib.objectmodel import import_from_mixin, we_are_translated
+from rpython.rlib.objectmodel import not_rpython
from rpython.rlib import jit
# Object imports
@@ -41,8 +42,9 @@
library in Restricted Python."""
import_from_mixin(DescrOperation)
+ @not_rpython
def initialize(self):
- """NOT_RPYTHON: only for initializing the space
+ """only for initializing the space
Setup all the object types and implementations.
"""
@@ -130,15 +132,11 @@
assert typedef is not None
return self.fromcache(TypeCache).getorbuild(typedef)
- @specialize.argtype(1)
+ @not_rpython # only for tests
def wrap(self, x):
- "Wraps the Python value 'x' into one of the wrapper classes."
- # You might notice that this function is rather conspicuously
- # not RPython. We can get away with this because the function
- # is specialized (see after the function body). Also worth
- # noting is that the isinstance's involving integer types
- # behave rather differently to how you might expect during
- # annotation (see pypy/annotation/builtin.py)
+ """ Wraps the Python value 'x' into one of the wrapper classes. This
+ should only be used for tests, in real code you need to use the
+ explicit new* methods."""
if x is None:
return self.w_None
if isinstance(x, OperationError):
@@ -236,15 +234,15 @@
self.wrap("refusing to wrap cpython value %r" % (x,))
)
+ @not_rpython
def wrap_exception_cls(self, x):
- """NOT_RPYTHON"""
if hasattr(self, 'w_' + x.__name__):
w_result = getattr(self, 'w_' + x.__name__)
return w_result
return None
+ @not_rpython
def wraplong(self, x):
- "NOT_RPYTHON"
if self.config.objspace.std.withsmalllong:
from rpython.rlib.rarithmetic import r_longlong
try:
@@ -257,8 +255,8 @@
return W_SmallLongObject(rx)
return W_LongObject.fromlong(x)
+ @not_rpython
def unwrap(self, w_obj):
- """NOT_RPYTHON"""
# _____ this code is here to support testing only _____
if isinstance(w_obj, W_Root):
return w_obj.unwrap(self)
@@ -579,7 +577,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:
@@ -679,7 +677,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