Author: Richard Plangger <planri...@gmail.com> Branch: vmprof-native Changeset: r90696:107955f416ca Date: 2017-03-14 14:30 +0100 http://bitbucket.org/pypy/pypy/changeset/107955f416ca/
Log: merge default diff too long, truncating to 2000 out of 37236 lines diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -60,6 +60,9 @@ ^lib_pypy/ctypes_config_cache/_.+_cache\.py$ ^lib_pypy/ctypes_config_cache/_.+_.+_\.py$ ^lib_pypy/_libmpdec/.+.o$ +^lib_pypy/.+.c$ +^lib_pypy/.+.o$ +^lib_pypy/.+.so$ ^pypy/doc/discussion/.+\.html$ ^include/.+\.h$ ^include/.+\.inl$ @@ -74,7 +77,7 @@ ^rpython/doc/_build/.*$ ^compiled ^.git/ -^.hypothesis/ +.hypothesis/ ^release/ ^rpython/_cache$ diff --git a/extra_tests/README.txt b/extra_tests/README.txt new file mode 100644 --- /dev/null +++ b/extra_tests/README.txt @@ -0,0 +1,5 @@ +The tests in this directory are a complement to lib-python/3/test/. + +They are meant to run on top of a compiled pypy3 or CPython3.5 in an +environment containing at least pytest and hypothesis, using a command like +'pytest extra_tests/'. diff --git a/extra_tests/pytest.ini b/extra_tests/pytest.ini new file mode 100644 diff --git a/extra_tests/test_unicode.py b/extra_tests/test_unicode.py new file mode 100644 --- /dev/null +++ b/extra_tests/test_unicode.py @@ -0,0 +1,34 @@ +import pytest +from hypothesis import strategies as st +from hypothesis import given, settings, example + +from unicodedata import normalize + +# For every (n1, n2, n3) triple, applying n1 then n2 must be the same +# as applying n3. +# Reference: http://unicode.org/reports/tr15/#Design_Goals +compositions = [ + ('NFC', 'NFC', 'NFC'), + ('NFC', 'NFD', 'NFD'), + ('NFC', 'NFKC', 'NFKC'), + ('NFC', 'NFKD', 'NFKD'), + ('NFD', 'NFC', 'NFC'), + ('NFD', 'NFD', 'NFD'), + ('NFD', 'NFKC', 'NFKC'), + ('NFD', 'NFKD', 'NFKD'), + ('NFKC', 'NFC', 'NFKC'), + ('NFKC', 'NFD', 'NFKD'), + ('NFKC', 'NFKC', 'NFKC'), + ('NFKC', 'NFKD', 'NFKD'), + ('NFKD', 'NFC', 'NFKC'), + ('NFKD', 'NFD', 'NFKD'), + ('NFKD', 'NFKC', 'NFKC'), + ('NFKD', 'NFKD', 'NFKD'), +] + +@pytest.mark.parametrize('norm1, norm2, norm3', compositions) +@settings(max_examples=1000) +@example(s=u'---\uafb8\u11a7---') # issue 2289 +@given(s=st.text()) +def test_composition(s, norm1, norm2, norm3): + assert normalize(norm2, normalize(norm1, s)) == normalize(norm3, s) diff --git a/lib-python/2.7/collections.py b/lib-python/2.7/collections.py --- a/lib-python/2.7/collections.py +++ b/lib-python/2.7/collections.py @@ -33,6 +33,10 @@ from __pypy__ import reversed_dict as _reversed_dict except ImportError: _reversed_dict = None # don't have ordered dicts +try: + from __pypy__ import dict_popitem_first as _dict_popitem_first +except ImportError: + _dict_popitem_first = None try: from thread import get_ident as _get_ident @@ -44,6 +48,17 @@ ### OrderedDict ################################################################################ +if _dict_popitem_first is None: + def _dict_popitem_first(self): + it = dict.iteritems(self) + try: + k, v = it.next() + except StopIteration: + raise KeyError('dictionary is empty') + dict.__delitem__(self, k) + return (k, v) + + class OrderedDict(dict): '''Dictionary that remembers insertion order. @@ -68,12 +83,7 @@ if last: return dict.popitem(self) else: - it = dict.__iter__(self) - try: - k = it.next() - except StopIteration: - raise KeyError('dictionary is empty') - return (k, self.pop(k)) + return _dict_popitem_first(self) def __repr__(self, _repr_running={}): 'od.__repr__() <==> repr(od)' diff --git a/lib-python/2.7/sysconfig.py b/lib-python/2.7/sysconfig.py --- a/lib-python/2.7/sysconfig.py +++ b/lib-python/2.7/sysconfig.py @@ -369,11 +369,8 @@ def _init_posix(vars): """Initialize the module as appropriate for POSIX systems.""" - # in cPython, _sysconfigdata is generated at build time, see _generate_posix_vars() - # in PyPy no such module exists - #from _sysconfigdata import build_time_vars - #vars.update(build_time_vars) - return + from _sysconfigdata import build_time_vars + vars.update(build_time_vars) def _init_non_posix(vars): """Initialize the module as appropriate for NT""" @@ -529,7 +526,9 @@ for suffix, mode, type_ in imp.get_suffixes(): if type_ == imp.C_EXTENSION: _CONFIG_VARS['SOABI'] = suffix.split('.')[1] - break + break + _CONFIG_VARS['INCLUDEPY'] = os.path.join(_CONFIG_VARS['prefix'], + 'include') if args: vals = [] diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py --- a/lib_pypy/_ctypes/function.py +++ b/lib_pypy/_ctypes/function.py @@ -604,7 +604,8 @@ """ # hack for performance: if restype is a "simple" primitive type, don't # allocate the buffer because it's going to be thrown away immediately - if self._is_primitive(restype) and not restype._is_pointer_like(): + if (self._is_primitive(restype) and restype._type_ != '?' + and not restype._is_pointer_like()): return result # shape = restype._ffishape_ diff --git a/lib_pypy/_sysconfigdata.py b/lib_pypy/_sysconfigdata.py new file mode 100644 --- /dev/null +++ b/lib_pypy/_sysconfigdata.py @@ -0,0 +1,5 @@ +import imp + +build_time_vars = { + "SO": [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION][0] +} diff --git a/lib_pypy/cffi/api.py b/lib_pypy/cffi/api.py --- a/lib_pypy/cffi/api.py +++ b/lib_pypy/cffi/api.py @@ -570,7 +570,10 @@ # we need 'libpypy-c.{so,dylib}', which should be by # default located in 'sys.prefix/bin' for installed # systems. - pythonlib = "pypy-c" + if sys.version_info < (3,): + pythonlib = "pypy-c" + else: + pythonlib = "pypy3-c" if hasattr(sys, 'prefix'): ensure('library_dirs', os.path.join(sys.prefix, 'bin')) # On uninstalled pypy's, the libpypy-c is typically found in @@ -756,21 +759,27 @@ def _load_backend_lib(backend, name, flags): + import os if name is None: if sys.platform != "win32": return backend.load_library(None, flags) name = "c" # Windows: load_library(None) fails, but this works # (backward compatibility hack only) - try: - if '.' not in name and '/' not in name: - raise OSError("library not found: %r" % (name,)) - return backend.load_library(name, flags) - except OSError: - import ctypes.util - path = ctypes.util.find_library(name) - if path is None: - raise # propagate the original OSError - return backend.load_library(path, flags) + first_error = None + if '.' in name or '/' in name or os.sep in name: + try: + return backend.load_library(name, flags) + except OSError as e: + first_error = e + import ctypes.util + path = ctypes.util.find_library(name) + if path is None: + msg = ("ctypes.util.find_library() did not manage " + "to locate a library called %r" % (name,)) + if first_error is not None: + msg = "%s. Additionally, %s" % (first_error, msg) + raise OSError(msg) + return backend.load_library(path, flags) def _make_ffi_library(ffi, libname, flags): backend = ffi._backend diff --git a/lib_pypy/cffi/backend_ctypes.py b/lib_pypy/cffi/backend_ctypes.py --- a/lib_pypy/cffi/backend_ctypes.py +++ b/lib_pypy/cffi/backend_ctypes.py @@ -112,11 +112,20 @@ def _make_cmp(name): cmpfunc = getattr(operator, name) def cmp(self, other): - if isinstance(other, CTypesData): + v_is_ptr = not isinstance(self, CTypesGenericPrimitive) + w_is_ptr = (isinstance(other, CTypesData) and + not isinstance(other, CTypesGenericPrimitive)) + if v_is_ptr and w_is_ptr: return cmpfunc(self._convert_to_address(None), other._convert_to_address(None)) + elif v_is_ptr or w_is_ptr: + return NotImplemented else: - return NotImplemented + if isinstance(self, CTypesGenericPrimitive): + self = self._value + if isinstance(other, CTypesGenericPrimitive): + other = other._value + return cmpfunc(self, other) cmp.func_name = name return cmp @@ -128,7 +137,7 @@ __ge__ = _make_cmp('__ge__') def __hash__(self): - return hash(type(self)) ^ hash(self._convert_to_address(None)) + return hash(self._convert_to_address(None)) def _to_string(self, maxlen): raise TypeError("string(): %r" % (self,)) @@ -137,14 +146,8 @@ class CTypesGenericPrimitive(CTypesData): __slots__ = [] - def __eq__(self, other): - return self is other - - def __ne__(self, other): - return self is not other - def __hash__(self): - return object.__hash__(self) + return hash(self._value) def _get_own_repr(self): return repr(self._from_ctypes(self._value)) diff --git a/lib_pypy/cffi/cparser.py b/lib_pypy/cffi/cparser.py --- a/lib_pypy/cffi/cparser.py +++ b/lib_pypy/cffi/cparser.py @@ -34,6 +34,9 @@ r'(Python|Python\s*\+\s*C|C\s*\+\s*Python)"\s*.') _r_star_const_space = re.compile( # matches "* const " r"[*]\s*((const|volatile|restrict)\b\s*)+") +_r_int_dotdotdot = re.compile(r"(\b(int|long|short|signed|unsigned|char)\s*)+" + r"\.\.\.") +_r_float_dotdotdot = re.compile(r"\b(double|float)\s*\.\.\.") def _get_parser(): global _parser_cache @@ -180,6 +183,10 @@ assert csource[p:p+3] == '...' csource = '%s __dotdotdot%d__ %s' % (csource[:p], number, csource[p+3:]) + # Replace "int ..." or "unsigned long int..." with "__dotdotdotint__" + csource = _r_int_dotdotdot.sub(' __dotdotdotint__ ', csource) + # Replace "float ..." or "double..." with "__dotdotdotfloat__" + csource = _r_float_dotdotdot.sub(' __dotdotdotfloat__ ', csource) # Replace all remaining "..." with the same name, "__dotdotdot__", # which is declared with a typedef for the purpose of C parsing. return csource.replace('...', ' __dotdotdot__ '), macros @@ -252,7 +259,8 @@ typenames += sorted(ctn) # csourcelines = ['typedef int %s;' % typename for typename in typenames] - csourcelines.append('typedef int __dotdotdot__;') + csourcelines.append('typedef int __dotdotdotint__, __dotdotdotfloat__,' + ' __dotdotdot__;') csourcelines.append(csource) csource = '\n'.join(csourcelines) if lock is not None: @@ -311,6 +319,8 @@ for decl in iterator: if decl.name == '__dotdotdot__': break + else: + assert 0 # try: self._inside_extern_python = '__cffi_extern_python_stop' @@ -322,15 +332,15 @@ raise CDefError("typedef does not declare any name", decl) quals = 0 - if (isinstance(decl.type.type, pycparser.c_ast.IdentifierType) - and decl.type.type.names[-1] == '__dotdotdot__'): + if (isinstance(decl.type.type, pycparser.c_ast.IdentifierType) and + decl.type.type.names[-1].startswith('__dotdotdot')): realtype = self._get_unknown_type(decl) elif (isinstance(decl.type, pycparser.c_ast.PtrDecl) and isinstance(decl.type.type, pycparser.c_ast.TypeDecl) and isinstance(decl.type.type.type, pycparser.c_ast.IdentifierType) and - decl.type.type.type.names == ['__dotdotdot__']): - realtype = model.unknown_ptr_type(decl.name) + decl.type.type.type.names[-1].startswith('__dotdotdot')): + realtype = self._get_unknown_ptr_type(decl) else: realtype, quals = self._get_type_and_quals( decl.type, name=decl.name, partial_length_ok=True) @@ -832,24 +842,25 @@ def _get_unknown_type(self, decl): typenames = decl.type.type.names - assert typenames[-1] == '__dotdotdot__' - if len(typenames) == 1: + if typenames == ['__dotdotdot__']: return model.unknown_type(decl.name) - if (typenames[:-1] == ['float'] or - typenames[:-1] == ['double']): - # not for 'long double' so far - result = model.UnknownFloatType(decl.name) - else: - for t in typenames[:-1]: - if t not in ['int', 'short', 'long', 'signed', - 'unsigned', 'char']: - raise FFIError(':%d: bad usage of "..."' % - decl.coord.line) - result = model.UnknownIntegerType(decl.name) + if typenames == ['__dotdotdotint__']: + if self._uses_new_feature is None: + self._uses_new_feature = "'typedef int... %s'" % decl.name + return model.UnknownIntegerType(decl.name) - if self._uses_new_feature is None: - self._uses_new_feature = "'typedef %s... %s'" % ( - ' '.join(typenames[:-1]), decl.name) + if typenames == ['__dotdotdotfloat__']: + # note: not for 'long double' so far + if self._uses_new_feature is None: + self._uses_new_feature = "'typedef float... %s'" % decl.name + return model.UnknownFloatType(decl.name) - return result + raise FFIError(':%d: unsupported usage of "..." in typedef' + % decl.coord.line) + + def _get_unknown_ptr_type(self, decl): + if decl.type.type.type.names == ['__dotdotdot__']: + return model.unknown_ptr_type(decl.name) + raise FFIError(':%d: unsupported usage of "..." in typedef' + % decl.coord.line) diff --git a/pypy/doc/build.rst b/pypy/doc/build.rst --- a/pypy/doc/build.rst +++ b/pypy/doc/build.rst @@ -49,7 +49,7 @@ ------------------------------- (**Note**: for some hints on how to translate the Python interpreter under Windows, see the `windows document`_ . For hints on how to cross-compile in -a chroot using scratchbox2, see the `arm document`_ in the +a chroot using scratchbox2, see the `arm document`_ in the `RPython documentation`_) .. _`windows document`: windows.html @@ -57,7 +57,7 @@ .. _`RPython documentation`: http://rpython.readthedocs.org The host Python needs to have CFFI installed. If translating on PyPy, CFFI is -already installed. If translating on CPython, you need to install it, e.g. +already installed. If translating on CPython, you need to install it, e.g. using ``pip install cffi``. To build PyPy on Unix using the C translation backend, you need at least a C @@ -116,7 +116,7 @@ On Fedora:: dnf install gcc make libffi-devel pkgconfig zlib-devel bzip2-devel \ - lib-sqlite3-devel ncurses-devel expat-devel openssl-devel tk-devel \ + sqlite-devel ncurses-devel expat-devel openssl-devel tk-devel \ gdbm-devel \ xz-devel # For lzma on PyPy3. @@ -162,7 +162,8 @@ import libraries in the `out-of-line API mode`_. This is done by the following command:: - PYTHONPATH=. ./pypy-c pypy/tool/build_cffi_imports.py + cd pypy/goal + PYTHONPATH=../.. ./pypy-c ../tool/build_cffi_imports.py .. _`out-of-line API mode`: http://cffi.readthedocs.org/en/latest/overview.html#real-example-api-level-out-of-line @@ -185,7 +186,7 @@ imported the first time. :: - + cd pypy/tool/release ./package.py pypy-VER-PLATFORM @@ -222,5 +223,3 @@ to continue normally. If the default path is usable, most code will be fine. However, the ``sys.prefix`` will be unset and some existing libraries assume that this is never the case. - - diff --git a/pypy/doc/conf.py b/pypy/doc/conf.py --- a/pypy/doc/conf.py +++ b/pypy/doc/conf.py @@ -17,6 +17,7 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.append(os.path.abspath('.')) +sys.path.append(os.path.abspath('../../')) # -- Read The Docs theme config ------------------------------------------------ diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst --- a/pypy/doc/cpython_differences.rst +++ b/pypy/doc/cpython_differences.rst @@ -483,6 +483,11 @@ the rest is kept. If you return an unexpected string from ``__hex__()`` you get an exception (or a crash before CPython 2.7.13). +* PyPy3: ``__class__`` attritube assignment between heaptypes and non heaptypes. + CPython allows that for module subtypes, but not for e.g. ``int`` + or ``float`` subtypes. Currently PyPy does not support the + ``__class__`` attribute assignment for any non heaptype subtype. + .. _`is ignored in PyPy`: http://bugs.python.org/issue14621 .. _`little point`: http://events.ccc.de/congress/2012/Fahrplan/events/5152.en.html .. _`#2072`: https://bitbucket.org/pypy/pypy/issue/2072/ diff --git a/pypy/doc/faq.rst b/pypy/doc/faq.rst --- a/pypy/doc/faq.rst +++ b/pypy/doc/faq.rst @@ -156,19 +156,30 @@ Does PyPy have a GIL? Why? ------------------------------------------------- -Yes, PyPy has a GIL. Removing the GIL is very hard. The problems are -essentially the same as with CPython (including the fact that our -garbage collectors are not thread-safe so far). Fixing it is possible, -as shown by Jython and IronPython, but difficult. It would require -adapting the whole source code of PyPy, including subtle decisions about -whether some effects are ok or not for the user (i.e. the Python -programmer). +Yes, PyPy has a GIL. Removing the GIL is very hard. On top of CPython, +you have two problems: (1) GC, in this case reference counting; (2) the +whole Python language. -Instead, since 2012, there is work going on on a still very experimental -:doc:`Software Transactional Memory <stm>` (STM) version of PyPy. This should give -an alternative PyPy which works without a GIL, while at the same time -continuing to give the Python programmer the complete illusion of having -one. +For PyPy, the hard issue is (2): by that I mean issues like what occurs +if a mutable object is changed from one thread and read from another +concurrently. This is a problem for *any* mutable type: it needs +careful review and fixes (fine-grained locks, mostly) through the +*whole* Python interpreter. It is a major effort, although not +completely impossible, as Jython/IronPython showed. This includes +subtle decisions about whether some effects are ok or not for the user +(i.e. the Python programmer). + +CPython has additionally the problem (1) of reference counting. With +PyPy, this sub-problem is simpler: we need to make our GC +multithread-aware. This is easier to do efficiently in PyPy than in +CPython. It doesn't solve the issue (2), though. + +Note that since 2012 there is work going on on a still very experimental +:doc:`Software Transactional Memory <stm>` (STM) version of PyPy. This +should give an alternative PyPy which works without a GIL, while at the +same time continuing to give the Python programmer the complete illusion +of having one. This work is currently a bit stalled because of its own +technical difficulties. Is PyPy more clever than CPython about Tail Calls? @@ -426,3 +437,11 @@ but so far there doesn't seem to be an overwhelming commercial interest in it. .. _`to make it happen`: windows.html#what-is-missing-for-a-full-64-bit-translation + + +How long will PyPy support Python2? +----------------------------------- + +Since RPython is built on top of Python2 and that is extremely unlikely to +change, the Python2 version of PyPy will be around "forever", i.e. as long as +PyPy itself is around. 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,35 @@ 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:: newbytes(t) + + The given argument is a rpython bytestring. Creates a wrapped object + of type :py:class:`bytes` (both on PyPy2 and PyPy3). + +.. 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 +247,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 +291,21 @@ If :py:obj:`w_x` is an application-level integer or long, return an interpreter-level :py:class:`rbigint`. Otherwise raise :py:exc:`TypeError`. +.. automethod:: pypy.interpreter.baseobjspace.ObjSpace.bytes_w(w_x) +.. automethod:: pypy.interpreter.baseobjspace.ObjSpace.text_w(w_x) + .. 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 diff --git a/pypy/doc/project-ideas.rst b/pypy/doc/project-ideas.rst --- a/pypy/doc/project-ideas.rst +++ b/pypy/doc/project-ideas.rst @@ -1,9 +1,29 @@ -Potential project list +Potential Project List ====================== -========================== +Google Summer of Code 2017 +-------------------------- + +PyPy is generally open to new ideas for Google Summer of Code. We are happy to accept good ideas around the PyPy ecosystem. If you need more information about the ideas we propose for this year please join us on irc, channel #pypy (freenode). If you are unsure, but still think that you can make a valuable contribution to PyPy, dont hesitate to contact us on #pypy or on our mailing list. + + +* **Optimize PyPy Memory Usage**: Sometimes PyPy consumes more memory than CPython. + Two examples: 1) PyPy seems to allocate and keep alive more strings when importing a big Python modules. + 2) The base interpreter size (cold VM started from a console) of PyPy is bigger than the one of CPython. + The general procedure of this project is: Run both CPython and PyPy of the same Python version and + compare the memory usage (using Massif or other tools). + If PyPy consumes a lot more memory then find and resolve the issue. + +* **VMProf + memory profiler**: vmprof by now has a memory profiler that can be used already. We want extend it with more features and resolve some current limitations. + +* **VMProf visualisations**: vmprof just shows a flame graph of the statistical profile and some more information about specific call sites. It would be very interesting to experiment with different information (such as memory, or even information generated by our jit compiler). + +* **Explicit typing in RPython**: PyPy wants to have better ways to specify the signature and class attribute types in RPython. See more information about this topic below on this page. + +* **Virtual Reality (VR) visualisations for vmprof**: This is a very open topic with lots of freedom to explore data visualisation for profiles. No VR hardware would be needed for this project. Either universities provide such hardware or in any other case we potentially can lend the VR hardware setup. + Simple tasks for newcomers -========================== +-------------------------- * Tkinter module missing support for threads: https://bitbucket.org/pypy/pypy/issue/1929/tkinter-broken-for-threaded-python-on-both @@ -15,9 +35,8 @@ https://bitbucket.org/pypy/pypy/issue/1942/support-for-af_xxx-sockets -================== Mid-to-large tasks -================== +------------------ Below is a list of projects that are interesting for potential contributors who are seriously interested in the PyPy project. They mostly share common @@ -81,7 +100,7 @@ module. Improving the jitviewer ------------------------- +----------------------- Analyzing performance of applications is always tricky. We have various tools, for example a `jitviewer`_ that help us analyze performance. diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -142,3 +142,50 @@ it is the standard ``OrderedDict.move_to_end()`` method, but the behavior is also available on Python 2.x or for the ``dict`` type by calling ``__pypy__.move_to_end(dict, key, last=True)``. + + +.. branch optinfo-into-bridges-3 + +Improve the optimization of branchy Python code by retaining more information +across failing guards. + + +.. branch: space-newtext + +Internal refactoring of ``space.wrap()``, which is now replaced with +explicitly-typed methods. Notably, there are now ``space.newbytes()`` +and ``space.newtext()``: these two methods are identical on PyPy 2.7 but +not on PyPy 3.x. The latter is used to get an app-level unicode string +by decoding the RPython string, assumed to be utf-8. + +.. branch: space-wrap + +.. branch: fix_bool_restype + +Fix for ``ctypes.c_bool``-returning ctypes functions + +.. branch: fix-cpyext-releasebuffer + +Improve handling of the Py3-style buffer slots in cpyext: fix memoryviews +keeping objects alive forever (missing decref), and make sure that +bf_releasebuffer is called when it should, e.g. from PyBuffer_Release. + +.. branch: fix-global + +Fix bug (bad reported info) when asked to translate SyntaxWarning to +SyntaxError. + +.. branch: optinfo-into-bridges-3 + +Improve the optimization of branchy Python code by retaining more +information across failing guards. This is done by appending some +carefully encoded extra information into the resume code. + +.. branch: shadowstack-perf-2 + +Two changes that together bring the performance of shadowstack close to +asmgcc---close enough that we can now make shadowstack the default even +on Linux. This should remove a whole class of rare bugs introduced by +asmgcc. + +.. branch: fniephaus/fix-typo-1488123166752 diff --git a/pypy/goal/getnightly.py b/pypy/goal/getnightly.py --- a/pypy/goal/getnightly.py +++ b/pypy/goal/getnightly.py @@ -4,16 +4,24 @@ import os import py +TAR_OPTIONS = '-x -v --strip-components=2' +TAR = 'tar {options} -f {tarfile} {files}' + +def untar(tarfile, files): + cmd = TAR.format(options=TAR_OPTIONS, tarfile=tarfile, files=files) + os.system(cmd) + if sys.platform.startswith('linux'): arch = 'linux' cmd = 'wget "%s"' - tar = "tar -x -v --wildcards --strip-components=2 -f %s '*/bin/pypy' '*/bin/libpypy-c.so'" + TAR_OPTIONS += ' --wildcards' + binfiles = "'*/bin/pypy' '*/bin/libpypy-c.so'" if os.uname()[-1].startswith('arm'): arch += '-armhf-raspbian' elif sys.platform.startswith('darwin'): arch = 'osx' cmd = 'curl -O "%s"' - tar = "tar -x -v --strip-components=2 -f %s '*/bin/pypy'" + binfiles = "'*/bin/pypy'" else: print 'Cannot determine the platform, please update this script' sys.exit(1) @@ -34,6 +42,7 @@ filename = 'pypy-c-%s-latest-%s.tar.bz2' % (kind, arch) url = 'http://buildbot.pypy.org/nightly/%s/%s' % (branch, filename) tmp = py.path.local.mkdtemp() +pypy_latest = tmp.join(filename) mydir = tmp.chdir() print 'Downloading pypy to', tmp if os.system(cmd % url) != 0: @@ -41,4 +50,10 @@ print 'Extracting pypy binary' mydir.chdir() -os.system(tar % tmp.join(filename)) +untar(pypy_latest, binfiles) +include_dir = py.path.local('../../include') +if include_dir.check(dir=True): + include_dir.chdir() + untar(pypy_latest, '*/include/*') +else: + print 'WARNING: could not find the include/ dir' diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py --- a/pypy/goal/targetpypystandalone.py +++ b/pypy/goal/targetpypystandalone.py @@ -31,9 +31,9 @@ def create_entry_point(space, w_dict): if w_dict is not None: # for tests - w_entry_point = space.getitem(w_dict, space.wrap('entry_point')) - w_run_toplevel = space.getitem(w_dict, space.wrap('run_toplevel')) - w_initstdio = space.getitem(w_dict, space.wrap('initstdio')) + w_entry_point = space.getitem(w_dict, space.newtext('entry_point')) + w_run_toplevel = space.getitem(w_dict, space.newtext('run_toplevel')) + w_initstdio = space.getitem(w_dict, space.newtext('initstdio')) withjit = space.config.objspace.usemodules.pypyjit hashfunc = space.config.objspace.hash else: @@ -65,8 +65,8 @@ try: try: space.startup() - w_executable = space.wrap(argv[0]) - w_argv = space.newlist([space.wrap(s) for s in argv[1:]]) + w_executable = space.newtext(argv[0]) + w_argv = space.newlist([space.newtext(s) for s in argv[1:]]) w_exitcode = space.call_function(w_entry_point, w_executable, w_argv) exitcode = space.int_w(w_exitcode) # try to pull it all in @@ -76,7 +76,7 @@ except OperationError as e: debug("OperationError:") debug(" operror-type: " + e.w_type.getname(space)) - debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space)))) + debug(" operror-value: " + space.text_w(space.str(e.get_w_value(space)))) return 1 finally: try: @@ -84,7 +84,7 @@ except OperationError as e: debug("OperationError:") debug(" operror-type: " + e.w_type.getname(space)) - debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space)))) + debug(" operror-value: " + space.text_w(space.str(e.get_w_value(space)))) return 1 return exitcode @@ -123,7 +123,7 @@ try: # initialize sys.{path,executable,stdin,stdout,stderr} # (in unbuffered mode, to avoid troubles) and import site - space.appexec([w_path, space.wrap(home), w_initstdio], + space.appexec([w_path, space.newtext(home), w_initstdio], r"""(path, home, initstdio): import sys sys.path[:] = path @@ -141,7 +141,7 @@ if verbose: debug("OperationError:") debug(" operror-type: " + e.w_type.getname(space)) - debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space)))) + debug(" operror-value: " + space.text_w(space.str(e.get_w_value(space)))) return rffi.cast(rffi.INT, -1) finally: if must_leave: @@ -180,11 +180,11 @@ def _pypy_execute_source(source, c_argument): try: w_globals = space.newdict(module=True) - space.setitem(w_globals, space.wrap('__builtins__'), + space.setitem(w_globals, space.newtext('__builtins__'), space.builtin_modules['__builtin__']) - space.setitem(w_globals, space.wrap('c_argument'), - space.wrap(c_argument)) - space.appexec([space.wrap(source), w_globals], """(src, glob): + space.setitem(w_globals, space.newtext('c_argument'), + space.newint(c_argument)) + space.appexec([space.newtext(source), w_globals], """(src, glob): import sys stmt = compile(src, 'c callback', 'exec') if not hasattr(sys, '_pypy_execute_source'): @@ -195,7 +195,7 @@ except OperationError as e: debug("OperationError:") debug(" operror-type: " + e.w_type.getname(space)) - debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space)))) + debug(" operror-value: " + space.text_w(space.str(e.get_w_value(space)))) return -1 return 0 @@ -323,7 +323,7 @@ # obscure hack to stuff the translation options into the translated PyPy import pypy.module.sys options = make_dict(config) - wrapstr = 'space.wrap(%r)' % (options) + wrapstr = 'space.wrap(%r)' % (options) # import time pypy.module.sys.Module.interpleveldefs['pypy_translation_info'] = wrapstr if config.objspace.usemodules._cffi_backend: self.hack_for_cffi_modules(driver) diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py --- a/pypy/interpreter/argument.py +++ b/pypy/interpreter/argument.py @@ -363,7 +363,7 @@ i = 0 for w_key in keys_w: try: - key = space.str_w(w_key) + key = space.text_w(w_key) except OperationError as e: if e.match(space, space.w_TypeError): raise oefmt(space.w_TypeError, "keywords must be strings") @@ -547,11 +547,11 @@ except IndexError: name = '?' else: - w_enc = space.wrap(space.sys.defaultencoding) - w_err = space.wrap("replace") + w_enc = space.newtext(space.sys.defaultencoding) + w_err = space.newtext("replace") w_name = space.call_method(w_name, "encode", w_enc, w_err) - name = space.str_w(w_name) + name = space.text_w(w_name) break self.kwd_name = name diff --git a/pypy/interpreter/astcompiler/assemble.py b/pypy/interpreter/astcompiler/assemble.py --- a/pypy/interpreter/astcompiler/assemble.py +++ b/pypy/interpreter/astcompiler/assemble.py @@ -266,8 +266,8 @@ else: w_key = space.newtuple([obj, space.w_float]) elif space.is_w(w_type, space.w_complex): - w_real = space.getattr(obj, space.wrap("real")) - w_imag = space.getattr(obj, space.wrap("imag")) + w_real = space.getattr(obj, space.newtext("real")) + w_imag = space.getattr(obj, space.newtext("imag")) real = space.float_w(w_real) imag = space.float_w(w_imag) real_negzero = (real == 0.0 and @@ -366,7 +366,7 @@ space = self.space consts_w = [space.w_None] * space.len_w(w_consts) w_iter = space.iter(w_consts) - first = space.wrap(0) + first = space.newint(0) while True: try: w_key = space.next(w_iter) diff --git a/pypy/interpreter/astcompiler/ast.py b/pypy/interpreter/astcompiler/ast.py --- a/pypy/interpreter/astcompiler/ast.py +++ b/pypy/interpreter/astcompiler/ast.py @@ -13,7 +13,7 @@ "field %s is required for %T", name, w_obj) def check_string(space, w_obj): - if not (space.isinstance_w(w_obj, space.w_str) or + if not (space.isinstance_w(w_obj, space.w_bytes) or space.isinstance_w(w_obj, space.w_unicode)): raise oefmt(space.w_TypeError, "AST string must be of type str or unicode") @@ -48,10 +48,10 @@ "Hack around the fact we can't store tuples on a TypeDef." def __init__(self, fields): - self.fields = fields - - def __spacebind__(self, space): - return space.newtuple([space.wrap(field) for field in self.fields]) + assert fields == [] + + def spacebind(self, space): + return space.newtuple([]) class W_AST(W_Root): @@ -67,14 +67,14 @@ if w_dict is None: w_dict = space.newdict() w_type = space.type(self) - w_fields = space.getattr(w_type, space.wrap("_fields")) + w_fields = space.getattr(w_type, space.newtext("_fields")) for w_name in space.fixedview(w_fields): try: space.setitem(w_dict, w_name, space.getattr(self, w_name)) except OperationError: pass - w_attrs = space.findattr(w_type, space.wrap("_attributes")) + w_attrs = space.findattr(w_type, space.newtext("_attributes")) if w_attrs: for w_name in space.fixedview(w_attrs): try: @@ -93,12 +93,12 @@ def W_AST_new(space, w_type, __args__): node = space.allocate_instance(W_AST, w_type) - return space.wrap(node) + return node def W_AST_init(space, w_self, __args__): args_w, kwargs_w = __args__.unpack() fields_w = space.fixedview(space.getattr(space.type(w_self), - space.wrap("_fields"))) + space.newtext("_fields"))) num_fields = len(fields_w) if fields_w else 0 if args_w and len(args_w) != num_fields: if num_fields == 0: @@ -114,7 +114,7 @@ for i, w_field in enumerate(fields_w): space.setattr(w_self, w_field, args_w[i]) for field, w_value in kwargs_w.iteritems(): - space.setattr(w_self, space.wrap(field), w_value) + space.setattr(w_self, space.newtext(field), w_value) W_AST.typedef = typedef.TypeDef("_ast.AST", @@ -143,16 +143,16 @@ def make_new_type(self, space, name, base, fields, attributes): w_base = getattr(self, 'w_%s' % base) w_dict = space.newdict() - space.setitem_str(w_dict, '__module__', space.wrap('_ast')) + space.setitem_str(w_dict, '__module__', space.newtext('_ast')) if fields is not None: space.setitem_str(w_dict, "_fields", - space.newtuple([space.wrap(f) for f in fields])) + space.newtuple([space.newtext(f) for f in fields])) if attributes is not None: space.setitem_str(w_dict, "_attributes", - space.newtuple([space.wrap(a) for a in attributes])) + space.newtuple([space.newtext(a) for a in attributes])) w_type = space.call_function( space.w_type, - space.wrap(name), space.newtuple([w_base]), w_dict) + space.newtext(name), space.newtuple([w_base]), w_dict) setattr(self, 'w_%s' % name, w_type) def get(space): @@ -196,7 +196,7 @@ else: body_w = [node.to_object(space) for node in self.body] # stmt w_body = space.newlist(body_w) - space.setattr(w_node, space.wrap('body'), w_body) + space.setattr(w_node, space.newtext('body'), w_body) return w_node @staticmethod @@ -230,7 +230,7 @@ else: body_w = [node.to_object(space) for node in self.body] # stmt w_body = space.newlist(body_w) - space.setattr(w_node, space.wrap('body'), w_body) + space.setattr(w_node, space.newtext('body'), w_body) return w_node @staticmethod @@ -258,7 +258,7 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Expression) w_body = self.body.to_object(space) # expr - space.setattr(w_node, space.wrap('body'), w_body) + space.setattr(w_node, space.newtext('body'), w_body) return w_node @staticmethod @@ -293,7 +293,7 @@ else: body_w = [node.to_object(space) for node in self.body] # stmt w_body = space.newlist(body_w) - space.setattr(w_node, space.wrap('body'), w_body) + space.setattr(w_node, space.newtext('body'), w_body) return w_node @staticmethod @@ -390,26 +390,26 @@ def to_object(self, space): w_node = space.call_function(get(space).w_FunctionDef) - w_name = space.wrap(self.name) # identifier - space.setattr(w_node, space.wrap('name'), w_name) + w_name = space.newtext(self.name) # identifier + space.setattr(w_node, space.newtext('name'), w_name) w_args = self.args.to_object(space) # arguments - space.setattr(w_node, space.wrap('args'), w_args) + space.setattr(w_node, space.newtext('args'), w_args) if self.body is None: body_w = [] else: body_w = [node.to_object(space) for node in self.body] # stmt w_body = space.newlist(body_w) - space.setattr(w_node, space.wrap('body'), w_body) + space.setattr(w_node, space.newtext('body'), w_body) if self.decorator_list is None: decorator_list_w = [] else: decorator_list_w = [node.to_object(space) for node in self.decorator_list] # expr w_decorator_list = space.newlist(decorator_list_w) - space.setattr(w_node, space.wrap('decorator_list'), w_decorator_list) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('decorator_list'), w_decorator_list) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -420,7 +420,7 @@ w_decorator_list = get_field(space, w_node, 'decorator_list', False) w_lineno = get_field(space, w_node, 'lineno', False) w_col_offset = get_field(space, w_node, 'col_offset', False) - _name = space.realstr_w(w_name) + _name = space.realtext_w(w_name) if _name is None: raise_required_value(space, w_node, 'name') _args = arguments.from_object(space, w_args) @@ -463,30 +463,30 @@ def to_object(self, space): w_node = space.call_function(get(space).w_ClassDef) - w_name = space.wrap(self.name) # identifier - space.setattr(w_node, space.wrap('name'), w_name) + w_name = space.newtext(self.name) # identifier + space.setattr(w_node, space.newtext('name'), w_name) if self.bases is None: bases_w = [] else: bases_w = [node.to_object(space) for node in self.bases] # expr w_bases = space.newlist(bases_w) - space.setattr(w_node, space.wrap('bases'), w_bases) + space.setattr(w_node, space.newtext('bases'), w_bases) if self.body is None: body_w = [] else: body_w = [node.to_object(space) for node in self.body] # stmt w_body = space.newlist(body_w) - space.setattr(w_node, space.wrap('body'), w_body) + space.setattr(w_node, space.newtext('body'), w_body) if self.decorator_list is None: decorator_list_w = [] else: decorator_list_w = [node.to_object(space) for node in self.decorator_list] # expr w_decorator_list = space.newlist(decorator_list_w) - space.setattr(w_node, space.wrap('decorator_list'), w_decorator_list) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('decorator_list'), w_decorator_list) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -497,7 +497,7 @@ w_decorator_list = get_field(space, w_node, 'decorator_list', False) w_lineno = get_field(space, w_node, 'lineno', False) w_col_offset = get_field(space, w_node, 'col_offset', False) - _name = space.realstr_w(w_name) + _name = space.realtext_w(w_name) if _name is None: raise_required_value(space, w_node, 'name') bases_w = space.unpackiterable(w_bases) @@ -530,11 +530,11 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Return) w_value = self.value.to_object(space) if self.value is not None else space.w_None # expr - space.setattr(w_node, space.wrap('value'), w_value) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('value'), w_value) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -572,11 +572,11 @@ else: targets_w = [node.to_object(space) for node in self.targets] # expr w_targets = space.newlist(targets_w) - space.setattr(w_node, space.wrap('targets'), w_targets) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('targets'), w_targets) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -617,13 +617,13 @@ else: targets_w = [node.to_object(space) for node in self.targets] # expr w_targets = space.newlist(targets_w) - space.setattr(w_node, space.wrap('targets'), w_targets) + space.setattr(w_node, space.newtext('targets'), w_targets) w_value = self.value.to_object(space) # expr - space.setattr(w_node, space.wrap('value'), w_value) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('value'), w_value) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -663,15 +663,15 @@ def to_object(self, space): w_node = space.call_function(get(space).w_AugAssign) w_target = self.target.to_object(space) # expr - space.setattr(w_node, space.wrap('target'), w_target) + space.setattr(w_node, space.newtext('target'), w_target) w_op = operator_to_class[self.op - 1]().to_object(space) # operator - space.setattr(w_node, space.wrap('op'), w_op) + space.setattr(w_node, space.newtext('op'), w_op) w_value = self.value.to_object(space) # expr - space.setattr(w_node, space.wrap('value'), w_value) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('value'), w_value) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -719,19 +719,19 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Print) w_dest = self.dest.to_object(space) if self.dest is not None else space.w_None # expr - space.setattr(w_node, space.wrap('dest'), w_dest) + space.setattr(w_node, space.newtext('dest'), w_dest) if self.values is None: values_w = [] else: values_w = [node.to_object(space) for node in self.values] # expr w_values = space.newlist(values_w) - space.setattr(w_node, space.wrap('values'), w_values) - w_nl = space.wrap(self.nl) # bool - space.setattr(w_node, space.wrap('nl'), w_nl) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('values'), w_values) + w_nl = space.newbool(self.nl) # bool + space.setattr(w_node, space.newtext('nl'), w_nl) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -780,25 +780,25 @@ def to_object(self, space): w_node = space.call_function(get(space).w_For) w_target = self.target.to_object(space) # expr - space.setattr(w_node, space.wrap('target'), w_target) + space.setattr(w_node, space.newtext('target'), w_target) w_iter = self.iter.to_object(space) # expr - space.setattr(w_node, space.wrap('iter'), w_iter) + space.setattr(w_node, space.newtext('iter'), w_iter) if self.body is None: body_w = [] else: body_w = [node.to_object(space) for node in self.body] # stmt w_body = space.newlist(body_w) - space.setattr(w_node, space.wrap('body'), w_body) + space.setattr(w_node, space.newtext('body'), w_body) if self.orelse is None: orelse_w = [] else: orelse_w = [node.to_object(space) for node in self.orelse] # stmt w_orelse = space.newlist(orelse_w) - space.setattr(w_node, space.wrap('orelse'), w_orelse) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('orelse'), w_orelse) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -850,23 +850,23 @@ def to_object(self, space): w_node = space.call_function(get(space).w_While) w_test = self.test.to_object(space) # expr - space.setattr(w_node, space.wrap('test'), w_test) + space.setattr(w_node, space.newtext('test'), w_test) if self.body is None: body_w = [] else: body_w = [node.to_object(space) for node in self.body] # stmt w_body = space.newlist(body_w) - space.setattr(w_node, space.wrap('body'), w_body) + space.setattr(w_node, space.newtext('body'), w_body) if self.orelse is None: orelse_w = [] else: orelse_w = [node.to_object(space) for node in self.orelse] # stmt w_orelse = space.newlist(orelse_w) - space.setattr(w_node, space.wrap('orelse'), w_orelse) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('orelse'), w_orelse) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -914,23 +914,23 @@ def to_object(self, space): w_node = space.call_function(get(space).w_If) w_test = self.test.to_object(space) # expr - space.setattr(w_node, space.wrap('test'), w_test) + space.setattr(w_node, space.newtext('test'), w_test) if self.body is None: body_w = [] else: body_w = [node.to_object(space) for node in self.body] # stmt w_body = space.newlist(body_w) - space.setattr(w_node, space.wrap('body'), w_body) + space.setattr(w_node, space.newtext('body'), w_body) if self.orelse is None: orelse_w = [] else: orelse_w = [node.to_object(space) for node in self.orelse] # stmt w_orelse = space.newlist(orelse_w) - space.setattr(w_node, space.wrap('orelse'), w_orelse) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('orelse'), w_orelse) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -977,19 +977,19 @@ def to_object(self, space): w_node = space.call_function(get(space).w_With) w_context_expr = self.context_expr.to_object(space) # expr - space.setattr(w_node, space.wrap('context_expr'), w_context_expr) + space.setattr(w_node, space.newtext('context_expr'), w_context_expr) w_optional_vars = self.optional_vars.to_object(space) if self.optional_vars is not None else space.w_None # expr - space.setattr(w_node, space.wrap('optional_vars'), w_optional_vars) + space.setattr(w_node, space.newtext('optional_vars'), w_optional_vars) if self.body is None: body_w = [] else: body_w = [node.to_object(space) for node in self.body] # stmt w_body = space.newlist(body_w) - space.setattr(w_node, space.wrap('body'), w_body) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('body'), w_body) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1035,15 +1035,15 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Raise) w_type = self.type.to_object(space) if self.type is not None else space.w_None # expr - space.setattr(w_node, space.wrap('type'), w_type) + space.setattr(w_node, space.newtext('type'), w_type) w_inst = self.inst.to_object(space) if self.inst is not None else space.w_None # expr - space.setattr(w_node, space.wrap('inst'), w_inst) + space.setattr(w_node, space.newtext('inst'), w_inst) w_tback = self.tback.to_object(space) if self.tback is not None else space.w_None # expr - space.setattr(w_node, space.wrap('tback'), w_tback) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('tback'), w_tback) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1093,23 +1093,23 @@ else: body_w = [node.to_object(space) for node in self.body] # stmt w_body = space.newlist(body_w) - space.setattr(w_node, space.wrap('body'), w_body) + space.setattr(w_node, space.newtext('body'), w_body) if self.handlers is None: handlers_w = [] else: handlers_w = [node.to_object(space) for node in self.handlers] # excepthandler w_handlers = space.newlist(handlers_w) - space.setattr(w_node, space.wrap('handlers'), w_handlers) + space.setattr(w_node, space.newtext('handlers'), w_handlers) if self.orelse is None: orelse_w = [] else: orelse_w = [node.to_object(space) for node in self.orelse] # stmt w_orelse = space.newlist(orelse_w) - space.setattr(w_node, space.wrap('orelse'), w_orelse) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('orelse'), w_orelse) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1158,17 +1158,17 @@ else: body_w = [node.to_object(space) for node in self.body] # stmt w_body = space.newlist(body_w) - space.setattr(w_node, space.wrap('body'), w_body) + space.setattr(w_node, space.newtext('body'), w_body) if self.finalbody is None: finalbody_w = [] else: finalbody_w = [node.to_object(space) for node in self.finalbody] # stmt w_finalbody = space.newlist(finalbody_w) - space.setattr(w_node, space.wrap('finalbody'), w_finalbody) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('finalbody'), w_finalbody) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1207,13 +1207,13 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Assert) w_test = self.test.to_object(space) # expr - space.setattr(w_node, space.wrap('test'), w_test) + space.setattr(w_node, space.newtext('test'), w_test) w_msg = self.msg.to_object(space) if self.msg is not None else space.w_None # expr - space.setattr(w_node, space.wrap('msg'), w_msg) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('msg'), w_msg) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1255,11 +1255,11 @@ else: names_w = [node.to_object(space) for node in self.names] # alias w_names = space.newlist(names_w) - space.setattr(w_node, space.wrap('names'), w_names) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('names'), w_names) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1295,20 +1295,20 @@ def to_object(self, space): w_node = space.call_function(get(space).w_ImportFrom) - w_module = space.wrap(self.module) # identifier - space.setattr(w_node, space.wrap('module'), w_module) + w_module = space.newtext_or_none(self.module) # identifier + space.setattr(w_node, space.newtext('module'), w_module) if self.names is None: names_w = [] else: names_w = [node.to_object(space) for node in self.names] # alias w_names = space.newlist(names_w) - space.setattr(w_node, space.wrap('names'), w_names) - w_level = space.wrap(self.level) # int - space.setattr(w_node, space.wrap('level'), w_level) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('names'), w_names) + w_level = space.newint(self.level) # int + space.setattr(w_node, space.newtext('level'), w_level) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1318,7 +1318,7 @@ w_level = get_field(space, w_node, 'level', True) w_lineno = get_field(space, w_node, 'lineno', False) w_col_offset = get_field(space, w_node, 'col_offset', False) - _module = space.str_or_None_w(w_module) + _module = space.realtext_w(w_module) if not space.is_none(w_module) else None names_w = space.unpackiterable(w_names) _names = [alias.from_object(space, w_item) for w_item in names_w] _level = space.int_w(w_level) @@ -1351,15 +1351,15 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Exec) w_body = self.body.to_object(space) # expr - space.setattr(w_node, space.wrap('body'), w_body) + space.setattr(w_node, space.newtext('body'), w_body) w_globals = self.globals.to_object(space) if self.globals is not None else space.w_None # expr - space.setattr(w_node, space.wrap('globals'), w_globals) + space.setattr(w_node, space.newtext('globals'), w_globals) w_locals = self.locals.to_object(space) if self.locals is not None else space.w_None # expr - space.setattr(w_node, space.wrap('locals'), w_locals) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('locals'), w_locals) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1398,13 +1398,13 @@ if self.names is None: names_w = [] else: - names_w = [space.wrap(node) for node in self.names] # identifier + names_w = [space.newtext(node) for node in self.names] # identifier w_names = space.newlist(names_w) - space.setattr(w_node, space.wrap('names'), w_names) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('names'), w_names) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1413,7 +1413,7 @@ w_lineno = get_field(space, w_node, 'lineno', False) w_col_offset = get_field(space, w_node, 'col_offset', False) names_w = space.unpackiterable(w_names) - _names = [space.realstr_w(w_item) for w_item in names_w] + _names = [space.realtext_w(w_item) for w_item in names_w] _lineno = space.int_w(w_lineno) _col_offset = space.int_w(w_col_offset) return Global(_names, _lineno, _col_offset) @@ -1437,11 +1437,11 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Expr) w_value = self.value.to_object(space) # expr - space.setattr(w_node, space.wrap('value'), w_value) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('value'), w_value) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1472,10 +1472,10 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Pass) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1502,10 +1502,10 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Break) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1532,10 +1532,10 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Continue) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1628,17 +1628,17 @@ def to_object(self, space): w_node = space.call_function(get(space).w_BoolOp) w_op = boolop_to_class[self.op - 1]().to_object(space) # boolop - space.setattr(w_node, space.wrap('op'), w_op) + space.setattr(w_node, space.newtext('op'), w_op) if self.values is None: values_w = [] else: values_w = [node.to_object(space) for node in self.values] # expr w_values = space.newlist(values_w) - space.setattr(w_node, space.wrap('values'), w_values) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('values'), w_values) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1678,15 +1678,15 @@ def to_object(self, space): w_node = space.call_function(get(space).w_BinOp) w_left = self.left.to_object(space) # expr - space.setattr(w_node, space.wrap('left'), w_left) + space.setattr(w_node, space.newtext('left'), w_left) w_op = operator_to_class[self.op - 1]().to_object(space) # operator - space.setattr(w_node, space.wrap('op'), w_op) + space.setattr(w_node, space.newtext('op'), w_op) w_right = self.right.to_object(space) # expr - space.setattr(w_node, space.wrap('right'), w_right) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('right'), w_right) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1729,13 +1729,13 @@ def to_object(self, space): w_node = space.call_function(get(space).w_UnaryOp) w_op = unaryop_to_class[self.op - 1]().to_object(space) # unaryop - space.setattr(w_node, space.wrap('op'), w_op) + space.setattr(w_node, space.newtext('op'), w_op) w_operand = self.operand.to_object(space) # expr - space.setattr(w_node, space.wrap('operand'), w_operand) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('operand'), w_operand) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1775,13 +1775,13 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Lambda) w_args = self.args.to_object(space) # arguments - space.setattr(w_node, space.wrap('args'), w_args) + space.setattr(w_node, space.newtext('args'), w_args) w_body = self.body.to_object(space) # expr - space.setattr(w_node, space.wrap('body'), w_body) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('body'), w_body) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1823,15 +1823,15 @@ def to_object(self, space): w_node = space.call_function(get(space).w_IfExp) w_test = self.test.to_object(space) # expr - space.setattr(w_node, space.wrap('test'), w_test) + space.setattr(w_node, space.newtext('test'), w_test) w_body = self.body.to_object(space) # expr - space.setattr(w_node, space.wrap('body'), w_body) + space.setattr(w_node, space.newtext('body'), w_body) w_orelse = self.orelse.to_object(space) # expr - space.setattr(w_node, space.wrap('orelse'), w_orelse) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('orelse'), w_orelse) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1883,17 +1883,17 @@ else: keys_w = [node.to_object(space) for node in self.keys] # expr w_keys = space.newlist(keys_w) - space.setattr(w_node, space.wrap('keys'), w_keys) + space.setattr(w_node, space.newtext('keys'), w_keys) if self.values is None: values_w = [] else: values_w = [node.to_object(space) for node in self.values] # expr w_values = space.newlist(values_w) - space.setattr(w_node, space.wrap('values'), w_values) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('values'), w_values) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1935,11 +1935,11 @@ else: elts_w = [node.to_object(space) for node in self.elts] # expr w_elts = space.newlist(elts_w) - space.setattr(w_node, space.wrap('elts'), w_elts) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('elts'), w_elts) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -1976,17 +1976,17 @@ def to_object(self, space): w_node = space.call_function(get(space).w_ListComp) w_elt = self.elt.to_object(space) # expr - space.setattr(w_node, space.wrap('elt'), w_elt) + space.setattr(w_node, space.newtext('elt'), w_elt) if self.generators is None: generators_w = [] else: generators_w = [node.to_object(space) for node in self.generators] # comprehension w_generators = space.newlist(generators_w) - space.setattr(w_node, space.wrap('generators'), w_generators) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('generators'), w_generators) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -2027,17 +2027,17 @@ def to_object(self, space): w_node = space.call_function(get(space).w_SetComp) w_elt = self.elt.to_object(space) # expr - space.setattr(w_node, space.wrap('elt'), w_elt) + space.setattr(w_node, space.newtext('elt'), w_elt) if self.generators is None: generators_w = [] else: generators_w = [node.to_object(space) for node in self.generators] # comprehension w_generators = space.newlist(generators_w) - space.setattr(w_node, space.wrap('generators'), w_generators) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('generators'), w_generators) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -2080,19 +2080,19 @@ def to_object(self, space): w_node = space.call_function(get(space).w_DictComp) w_key = self.key.to_object(space) # expr - space.setattr(w_node, space.wrap('key'), w_key) + space.setattr(w_node, space.newtext('key'), w_key) w_value = self.value.to_object(space) # expr - space.setattr(w_node, space.wrap('value'), w_value) + space.setattr(w_node, space.newtext('value'), w_value) if self.generators is None: generators_w = [] else: generators_w = [node.to_object(space) for node in self.generators] # comprehension w_generators = space.newlist(generators_w) - space.setattr(w_node, space.wrap('generators'), w_generators) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('generators'), w_generators) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -2137,17 +2137,17 @@ def to_object(self, space): w_node = space.call_function(get(space).w_GeneratorExp) w_elt = self.elt.to_object(space) # expr - space.setattr(w_node, space.wrap('elt'), w_elt) + space.setattr(w_node, space.newtext('elt'), w_elt) if self.generators is None: generators_w = [] else: generators_w = [node.to_object(space) for node in self.generators] # comprehension w_generators = space.newlist(generators_w) - space.setattr(w_node, space.wrap('generators'), w_generators) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('generators'), w_generators) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -2185,11 +2185,11 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Yield) w_value = self.value.to_object(space) if self.value is not None else space.w_None # expr - space.setattr(w_node, space.wrap('value'), w_value) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('value'), w_value) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -2226,23 +2226,23 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Compare) w_left = self.left.to_object(space) # expr - space.setattr(w_node, space.wrap('left'), w_left) + space.setattr(w_node, space.newtext('left'), w_left) if self.ops is None: ops_w = [] else: ops_w = [cmpop_to_class[node - 1]().to_object(space) for node in self.ops] # cmpop w_ops = space.newlist(ops_w) - space.setattr(w_node, space.wrap('ops'), w_ops) + space.setattr(w_node, space.newtext('ops'), w_ops) if self.comparators is None: comparators_w = [] else: comparators_w = [node.to_object(space) for node in self.comparators] # expr w_comparators = space.newlist(comparators_w) - space.setattr(w_node, space.wrap('comparators'), w_comparators) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('comparators'), w_comparators) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -2296,27 +2296,27 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Call) w_func = self.func.to_object(space) # expr - space.setattr(w_node, space.wrap('func'), w_func) + space.setattr(w_node, space.newtext('func'), w_func) if self.args is None: args_w = [] else: args_w = [node.to_object(space) for node in self.args] # expr w_args = space.newlist(args_w) - space.setattr(w_node, space.wrap('args'), w_args) + space.setattr(w_node, space.newtext('args'), w_args) if self.keywords is None: keywords_w = [] else: keywords_w = [node.to_object(space) for node in self.keywords] # keyword w_keywords = space.newlist(keywords_w) - space.setattr(w_node, space.wrap('keywords'), w_keywords) + space.setattr(w_node, space.newtext('keywords'), w_keywords) w_starargs = self.starargs.to_object(space) if self.starargs is not None else space.w_None # expr - space.setattr(w_node, space.wrap('starargs'), w_starargs) + space.setattr(w_node, space.newtext('starargs'), w_starargs) w_kwargs = self.kwargs.to_object(space) if self.kwargs is not None else space.w_None # expr - space.setattr(w_node, space.wrap('kwargs'), w_kwargs) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('kwargs'), w_kwargs) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -2360,11 +2360,11 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Repr) w_value = self.value.to_object(space) # expr - space.setattr(w_node, space.wrap('value'), w_value) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('value'), w_value) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) return w_node @staticmethod @@ -2397,11 +2397,11 @@ def to_object(self, space): w_node = space.call_function(get(space).w_Num) w_n = self.n # object - space.setattr(w_node, space.wrap('n'), w_n) - w_lineno = space.wrap(self.lineno) # int - space.setattr(w_node, space.wrap('lineno'), w_lineno) - w_col_offset = space.wrap(self.col_offset) # int - space.setattr(w_node, space.wrap('col_offset'), w_col_offset) + space.setattr(w_node, space.newtext('n'), w_n) + w_lineno = space.newint(self.lineno) # int + space.setattr(w_node, space.newtext('lineno'), w_lineno) + w_col_offset = space.newint(self.col_offset) # int + space.setattr(w_node, space.newtext('col_offset'), w_col_offset) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit