[pypy-commit] pypy space-newtext: make space.wrap as @not_rpython
cfbolz
pypy.commits at gmail.com
Tue Nov 29 08:31:56 EST 2016
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: space-newtext
Changeset: r88737:5f267995aab4
Date: 2016-11-29 14:31 +0100
http://bitbucket.org/pypy/pypy/changeset/5f267995aab4/
Log: make space.wrap as @not_rpython
diff --git a/pypy/module/_file/interp_stream.py b/pypy/module/_file/interp_stream.py
--- a/pypy/module/_file/interp_stream.py
+++ b/pypy/module/_file/interp_stream.py
@@ -120,7 +120,7 @@
finally:
if acquired:
self.release_lock()
- return space.wrap(result) # YYY
+ return space.wrap(result)
%(name)s.unwrap_spec = [W_Stream, ObjSpace] + argtypes
""" % locals()).compile() in globals()
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
@@ -41,4 +41,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
@@ -758,4 +758,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
@@ -859,7 +859,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))
@@ -873,7 +873,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
@@ -8,7 +8,7 @@
from rpython.rlib.objectmodel import instantiate, specialize, is_annotation_constant
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, enforceargs
+from rpython.rlib.objectmodel import import_from_mixin, enforceargs, not_rpython
from rpython.rlib import jit
# Object imports
@@ -39,8 +39,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 +131,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):
@@ -161,11 +158,6 @@
return w_result
if isinstance(x, base_int):
return self.newint(x)
- return self._wrap_not_rpython(x)
-
- def _wrap_not_rpython(self, x):
- "NOT_RPYTHON"
- # _____ this code is here to support testing only _____
# we might get there in non-translated versions if 'x' is
# a long that fits the correct range.
@@ -214,15 +206,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:
@@ -235,8 +227,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)
More information about the pypy-commit
mailing list