[pypy-commit] pypy py3.5-newtext: hg merge 36e25bdf2bec

arigo pypy.commits at gmail.com
Tue Dec 20 07:00:12 EST 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5-newtext
Changeset: r89199:146082531f01
Date: 2016-12-20 11:59 +0100
http://bitbucket.org/pypy/pypy/changeset/146082531f01/

Log:	hg merge 36e25bdf2bec

diff --git a/pypy/doc/objspace.rst b/pypy/doc/objspace.rst
--- a/pypy/doc/objspace.rst
+++ b/pypy/doc/objspace.rst
@@ -188,6 +188,7 @@
 
 .. py:function:: wrap(x)
 
+   **Deprecated! Eventually this method should disappear.**
    Returns a wrapped object that is a reference to the interpreter-level object
    :py:obj:`x`. This can be used either on simple immutable objects (integers,
    strings, etc) to create a new wrapped object, or on instances of :py:class:`W_Root`
@@ -196,6 +197,30 @@
    be directly exposed to application-level code in this way - functions, frames,
    code objects, etc.
 
+.. py:function:: newint(i)
+
+   Creates a wrapped object holding an integral value. `newint` creates an object
+   of type `W_IntObject`.
+
+.. py:function:: newlong(l)
+
+   Creates a wrapped object holding an integral value. The main difference to newint
+   is the type of the argument (which is rpython.rlib.rbigint.rbigint). On PyPy3 this
+   method will return an :py:class:`int` (PyPy2 it returns a :py:class:`long`).
+
+.. py:function:: newtext(t)
+
+   The given argument is a rpython bytestring. Creates a wrapped object
+   of type :py:class:`str`.  On PyPy3 this will return a wrapped unicode
+   object. The object will hold a utf-8-nosg decoded value of `t`.
+   The "utf-8-nosg" codec used here is slightly different from the
+   "utf-8" implemented in Python 2 or Python 3: it is defined as utf-8
+   without any special handling of surrogate characters.  They are
+   encoded using the same three-bytes sequence that encodes any char in
+   the range from ``'\u0800'`` to ``'\uffff'``.
+
+   PyPy2 will return a bytestring object. No encoding/decoding steps will be applied.
+
 .. py:function:: newbool(b)
 
    Creates a wrapped :py:class:`bool` object from an :ref:`interpreter-level <interpreter-level>`
@@ -217,15 +242,18 @@
 
    Creates a new slice object.
 
-.. py:function:: newstring(asciilist)
+.. py:function:: newunicode(ustr)
 
-   Creates a string from a list of wrapped integers. Note that this may not be
-   a very useful method; usually you can just write ``space.wrap("mystring")``.
+   Creates a Unicode string from an rpython unicode string.
+   This method may disappear soon and be replaced by :py:function:`newutf8()`.
 
-.. py:function:: newunicode(codelist)
+.. py:function:: newutf8(bytestr)
 
-   Creates a Unicode string from a list of integers (code points).
+   Creates a Unicode string from an rpython byte string, decoded as
+   "utf-8-nosg".  On PyPy3 it is the same as :py:function:`newtext()`.
 
+Many more space operations can be found in `pypy/interpeter/baseobjspace.py` and
+`pypy/objspace/std/objspace.py`.
 
 Conversions from Application Level to Interpreter Level
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -258,11 +286,28 @@
    If :py:obj:`w_x` is an application-level integer or long, return an interpreter-level
    :py:class:`rbigint`. Otherwise raise :py:exc:`TypeError`.
 
+.. py:function:: text_w(w_x)
+
+   Takes an application level :py:class:`str` and converts it to a rpython byte string.
+   PyPy3 this method will return an utf-8-nosg encoded result.
+
+.. py:function:: bytes_w(w_x)
+
+   Takes an application level :py:class:`bytes` (PyPy2 this equals `str`) and returns a rpython
+   byte string.
+
 .. py:function:: str_w(w_x)
 
+   **Deprecated. use text_w or bytes_w instead**
    If :py:obj:`w_x` is an application-level string, return an interpreter-level string.
    Otherwise raise :py:exc:`TypeError`.
 
+.. py:function:: unicode_w(w_x)
+
+   Takes an application level :py:class:`unicode` and return an
+   interpreter-level unicode string.  This method may disappear soon and
+   be replaced by :py:function:`text_w()`.
+
 .. py:function:: float_w(w_x)
 
    If :py:obj:`w_x` is an application-level float, integer or long, return an


More information about the pypy-commit mailing list