Author: Ronan Lamy <ronan.l...@gmail.com>
Branch: py3.6
Changeset: r92878:40e3c2a486e9
Date: 2017-10-30 01:18 +0000
http://bitbucket.org/pypy/pypy/changeset/40e3c2a486e9/

Log:    hg merge py3.5

diff too long, truncating to 2000 out of 11351 lines

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -75,6 +75,8 @@
 ^lib_pypy/.+.c$
 ^lib_pypy/.+.o$
 ^lib_pypy/.+.so$
+^lib_pypy/.+.pyd$
+^lib_pypy/Release/
 ^pypy/doc/discussion/.+\.html$
 ^include/.+\.h$
 ^include/.+\.inl$
diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -40,3 +40,7 @@
 2875f328eae2216a87f3d6f335092832eb031f56 release-pypy3.5-v5.7.1
 c925e73810367cd960a32592dd7f728f436c125c release-pypy2.7-v5.8.0
 a37ecfe5f142bc971a86d17305cc5d1d70abec64 release-pypy3.5-v5.8.0
+03d614975835870da65ff0481e1edad68ebbcb8d release-pypy2.7-v5.9.0
+d72f9800a42b46a8056951b1da2426d2c2d8d502 release-pypy3.5-v5.9.0
+03d614975835870da65ff0481e1edad68ebbcb8d release-pypy2.7-v5.9.0
+84a2f3e6a7f88f2fe698e473998755b3bd1a12e2 release-pypy2.7-v5.9.0
diff --git a/lib-python/3/ctypes/test/test_bitfields.py 
b/lib-python/3/ctypes/test/test_bitfields.py
--- a/lib-python/3/ctypes/test/test_bitfields.py
+++ b/lib-python/3/ctypes/test/test_bitfields.py
@@ -1,5 +1,5 @@
 from ctypes import *
-from ctypes.test import need_symbol
+from ctypes.test import need_symbol, xfail
 import unittest
 import os
 
@@ -278,6 +278,7 @@
         self.assertEqual(b, b'\xef\xcd\xab\x21')
 
     @need_symbol('c_uint32')
+    @xfail
     def test_uint32_swap_big_endian(self):
         # Issue #23319
         class Big(BigEndianStructure):
diff --git a/lib-python/3/ctypes/test/test_byteswap.py 
b/lib-python/3/ctypes/test/test_byteswap.py
--- a/lib-python/3/ctypes/test/test_byteswap.py
+++ b/lib-python/3/ctypes/test/test_byteswap.py
@@ -2,6 +2,7 @@
 from binascii import hexlify
 
 from ctypes import *
+from test.support import impl_detail
 
 def bin(s):
     return hexlify(memoryview(s)).decode().upper()
@@ -22,6 +23,7 @@
             setattr(bits, "i%s" % i, 1)
             dump(bits)
 
+    @impl_detail("slots are irrelevant on PyPy", pypy=False)
     def test_slots(self):
         class BigPoint(BigEndianStructure):
             __slots__ = ()
diff --git a/lib-python/3/ctypes/test/test_frombuffer.py 
b/lib-python/3/ctypes/test/test_frombuffer.py
--- a/lib-python/3/ctypes/test/test_frombuffer.py
+++ b/lib-python/3/ctypes/test/test_frombuffer.py
@@ -85,7 +85,6 @@
         del a
         gc.collect()  # Should not crash
 
-    @xfail
     def test_from_buffer_copy(self):
         a = array.array("i", range(16))
         x = (c_int * 16).from_buffer_copy(a)
diff --git a/lib-python/3/ctypes/test/test_values.py 
b/lib-python/3/ctypes/test/test_values.py
--- a/lib-python/3/ctypes/test/test_values.py
+++ b/lib-python/3/ctypes/test/test_values.py
@@ -4,6 +4,7 @@
 
 import unittest
 import sys
+from test.support import cpython_only
 from ctypes import *
 
 import _ctypes_test
@@ -28,6 +29,7 @@
         ctdll = CDLL(_ctypes_test.__file__)
         self.assertRaises(ValueError, c_int.in_dll, ctdll, "Undefined_Symbol")
 
+@cpython_only
 class PythonValuesTestCase(unittest.TestCase):
     """This test only works when python itself is a dll/shared library"""
 
diff --git a/lib-python/3/test/test_bytes.py b/lib-python/3/test/test_bytes.py
--- a/lib-python/3/test/test_bytes.py
+++ b/lib-python/3/test/test_bytes.py
@@ -780,7 +780,6 @@
         self.assertIs(type(BytesSubclass(A())), BytesSubclass)
 
     # Test PyBytes_FromFormat()
-    @test.support.impl_detail("don't test cpyext here")
     def test_from_format(self):
         ctypes = test.support.import_module('ctypes')
         _testcapi = test.support.import_module('_testcapi')
diff --git a/lib-python/3/test/test_unicode.py 
b/lib-python/3/test/test_unicode.py
--- a/lib-python/3/test/test_unicode.py
+++ b/lib-python/3/test/test_unicode.py
@@ -2436,6 +2436,10 @@
     # Test PyUnicode_FromFormat()
     def test_from_format(self):
         support.import_module('ctypes')
+        try:
+            from ctypes import pythonapi
+        except ImportError:
+            self.skipTest( "no pythonapi in ctypes")
         from ctypes import (
             pythonapi, py_object, sizeof,
             c_int, c_long, c_longlong, c_ssize_t,
diff --git a/lib_pypy/_ctypes/array.py b/lib_pypy/_ctypes/array.py
--- a/lib_pypy/_ctypes/array.py
+++ b/lib_pypy/_ctypes/array.py
@@ -8,9 +8,14 @@
 class ArrayMeta(_CDataMeta):
     def __new__(self, name, cls, typedict):
         res = type.__new__(self, name, cls, typedict)
+
         if cls == (_CData,): # this is the Array class defined below
+            res._ffiarray = None
             return res
-
+        if not hasattr(res, '_length_') or not isinstance(res._length_, int):
+            raise AttributeError(
+                "class must define a '_length_' attribute, "
+                "which must be a positive integer")
         ffiarray = res._ffiarray = _rawffi.Array(res._type_._ffishape_)
         subletter = getattr(res._type_, '_type_', None)
         if subletter == 'c':
@@ -55,7 +60,7 @@
                 for i in range(len(val)):
                     target[i] = val[i]
                 if len(val) < self._length_:
-                    target[len(val)] = '\x00'
+                    target[len(val)] = u'\x00'
             res.value = property(getvalue, setvalue)
 
         res._ffishape_ = (ffiarray, res._length_)
@@ -164,7 +169,7 @@
     if letter == 'c':
         return b"".join(l)
     if letter == 'u':
-        return "".join(l)
+        return u"".join(l)
     return l
 
 class Array(_CData, metaclass=ArrayMeta):
diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -165,6 +165,10 @@
     def _get_buffer_value(self):
         return self._buffer[0]
 
+    def _copy_to(self, addr):
+        target = type(self).from_address(addr)._buffer
+        target[0] = self._get_buffer_value()
+
     def _to_ffi_param(self):
         if self.__class__._is_pointer_like():
             return self._get_buffer_value()
diff --git a/lib_pypy/_ctypes/pointer.py b/lib_pypy/_ctypes/pointer.py
--- a/lib_pypy/_ctypes/pointer.py
+++ b/lib_pypy/_ctypes/pointer.py
@@ -113,7 +113,9 @@
         cobj = self._type_.from_param(value)
         if ensure_objects(cobj) is not None:
             store_reference(self, index, cobj._objects)
-        self._subarray(index)[0] = cobj._get_buffer_value()
+        address = self._buffer[0]
+        address += index * sizeof(self._type_)
+        cobj._copy_to(address)
 
     def __bool__(self):
         return self._buffer[0] != 0
diff --git a/lib_pypy/_ctypes/primitive.py b/lib_pypy/_ctypes/primitive.py
--- a/lib_pypy/_ctypes/primitive.py
+++ b/lib_pypy/_ctypes/primitive.py
@@ -232,9 +232,6 @@
 
         elif tp == 'u':
             def _setvalue(self, val):
-                if isinstance(val, bytes):
-                    val = val.decode(ConvMode.encoding, ConvMode.errors)
-                # possible if we use 'ignore'
                 if val:
                     self._buffer[0] = val
             def _getvalue(self):
@@ -243,8 +240,6 @@
 
         elif tp == 'c':
             def _setvalue(self, val):
-                if isinstance(val, str):
-                    val = val.encode(ConvMode.encoding, ConvMode.errors)
                 if val:
                     self._buffer[0] = val
             def _getvalue(self):
diff --git a/lib_pypy/_ctypes/structure.py b/lib_pypy/_ctypes/structure.py
--- a/lib_pypy/_ctypes/structure.py
+++ b/lib_pypy/_ctypes/structure.py
@@ -290,6 +290,11 @@
     def _get_buffer_value(self):
         return self._buffer.buffer
 
+    def _copy_to(self, addr):
+        from ctypes import memmove
+        origin = self._get_buffer_value()
+        memmove(addr, origin, self._fficompositesize_)
+
     def _to_ffi_param(self):
         return self._buffer
 
diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py
--- a/lib_pypy/_curses.py
+++ b/lib_pypy/_curses.py
@@ -404,7 +404,7 @@
         return val
 
     def get_wch(self, *args):
-        wch = ffi.new("int[1]")
+        wch = ffi.new("wint_t[1]")
         if len(args) == 0:
             val = lib.wget_wch(self._win, wch)
         elif len(args) == 2:
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -1080,21 +1080,25 @@
         if '\0' in sql:
             raise ValueError("the query contains a null character")
 
-        first_word = sql.lstrip().split(" ")[0].upper()
-        if first_word == "":
+        
+        if sql:
+            first_word = sql.lstrip().split()[0].upper()
+            if first_word == '':
+                self._type = _STMT_TYPE_INVALID
+            if first_word == "SELECT":
+                self._type = _STMT_TYPE_SELECT
+            elif first_word == "INSERT":
+                self._type = _STMT_TYPE_INSERT
+            elif first_word == "UPDATE":
+                self._type = _STMT_TYPE_UPDATE
+            elif first_word == "DELETE":
+                self._type = _STMT_TYPE_DELETE
+            elif first_word == "REPLACE":
+                self._type = _STMT_TYPE_REPLACE
+            else:
+                self._type = _STMT_TYPE_OTHER
+        else:
             self._type = _STMT_TYPE_INVALID
-        elif first_word == "SELECT":
-            self._type = _STMT_TYPE_SELECT
-        elif first_word == "INSERT":
-            self._type = _STMT_TYPE_INSERT
-        elif first_word == "UPDATE":
-            self._type = _STMT_TYPE_UPDATE
-        elif first_word == "DELETE":
-            self._type = _STMT_TYPE_DELETE
-        elif first_word == "REPLACE":
-            self._type = _STMT_TYPE_REPLACE
-        else:
-            self._type = _STMT_TYPE_OTHER
 
         if isinstance(sql, unicode):
             sql = sql.encode('utf-8')
diff --git a/lib_pypy/cffi.egg-info/PKG-INFO b/lib_pypy/cffi.egg-info/PKG-INFO
--- a/lib_pypy/cffi.egg-info/PKG-INFO
+++ b/lib_pypy/cffi.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: cffi
-Version: 1.11.1
+Version: 1.11.2
 Summary: Foreign Function Interface for Python calling C code.
 Home-page: http://cffi.readthedocs.org
 Author: Armin Rigo, Maciej Fijalkowski
diff --git a/lib_pypy/cffi/__init__.py b/lib_pypy/cffi/__init__.py
--- a/lib_pypy/cffi/__init__.py
+++ b/lib_pypy/cffi/__init__.py
@@ -4,8 +4,8 @@
 from .api import FFI
 from .error import CDefError, FFIError, VerificationError, VerificationMissing
 
-__version__ = "1.11.1"
-__version_info__ = (1, 11, 1)
+__version__ = "1.11.2"
+__version_info__ = (1, 11, 2)
 
 # The verifier module file names are based on the CRC32 of a string that
 # contains the following version number.  It may be older than __version__
diff --git a/lib_pypy/cffi/_cffi_include.h b/lib_pypy/cffi/_cffi_include.h
--- a/lib_pypy/cffi/_cffi_include.h
+++ b/lib_pypy/cffi/_cffi_include.h
@@ -238,9 +238,9 @@
 _CFFI_UNUSED_FN static PyObject *_cffi_from_c_char16_t(uint16_t x)
 {
     if (sizeof(_cffi_wchar_t) == 2)
-        return _cffi_from_c_wchar_t(x);
+        return _cffi_from_c_wchar_t((_cffi_wchar_t)x);
     else
-        return _cffi_from_c_wchar3216_t(x);
+        return _cffi_from_c_wchar3216_t((int)x);
 }
 
 _CFFI_UNUSED_FN static int _cffi_to_c_char32_t(PyObject *o)
@@ -254,7 +254,7 @@
 _CFFI_UNUSED_FN static PyObject *_cffi_from_c_char32_t(int x)
 {
     if (sizeof(_cffi_wchar_t) == 4)
-        return _cffi_from_c_wchar_t(x);
+        return _cffi_from_c_wchar_t((_cffi_wchar_t)x);
     else
         return _cffi_from_c_wchar3216_t(x);
 }
diff --git a/lib_pypy/cffi/_embedding.h b/lib_pypy/cffi/_embedding.h
--- a/lib_pypy/cffi/_embedding.h
+++ b/lib_pypy/cffi/_embedding.h
@@ -247,7 +247,7 @@
 
         if (f != NULL && f != Py_None) {
             PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME
-                               "\ncompiled with cffi version: 1.11.1"
+                               "\ncompiled with cffi version: 1.11.2"
                                "\n_cffi_backend module: ", f);
             modules = PyImport_GetModuleDict();
             mod = PyDict_GetItemString(modules, "_cffi_backend");
diff --git a/pypy/TODO b/pypy/TODO
--- a/pypy/TODO
+++ b/pypy/TODO
@@ -1,18 +1,4 @@
-TODO for the python3 test suite:
-
-* test_memoryview
-   Needs bytes/str changes. Probably easy. Work for this has begun on
-   py3k-memoryview (by mjacob) https://bugs.pypy.org/issue1542
-
-own-tests:
-
-* module/test_lib_pypy
-  These crash the buildbots (via SyntaxErrors): others were really
-  made to run under Python 2.x and so simply fail
-
-* module.cpyext.test.test_structseq test_StructSeq
-  structseq now subclasses tuple on py3, which breaks how
-  BaseCpyTypeDescr.realize allocates it
+...
 
 
 antocuni's older TODO:
@@ -20,14 +6,6 @@
 * run coverage against the parser/astbuilder/astcompiler: it's probably full of
 dead code because the grammar changed
 
-* re-enable strategies https://bugs.pypy.org/issue1540 :
- - re-enable IntDictStrategy
- - re-enable StdObjSpace.listview_str
- - re-enable the kwargs dict strategy in dictmultiobject.py
- - re-enable view_as_kwargs
-
-* unskip numpypy tests in module/test_lib_pypy/numpypy/
-
 * optimize W_UnicodeObject, right now it stores both an unicode and an utf8
 version of the same string
 
diff --git a/pypy/doc/build.rst b/pypy/doc/build.rst
--- a/pypy/doc/build.rst
+++ b/pypy/doc/build.rst
@@ -119,7 +119,7 @@
 
 To run untranslated tests, you need the Boehm garbage collector libgc.
 
-On recent Debian and Ubuntu (like 17.04), this is the command to install
+On recent Debian and Ubuntu (16.04 onwards), this is the command to install
 all build-time dependencies::
 
     apt-get install gcc make libffi-dev pkg-config zlib1g-dev libbz2-dev \
@@ -127,7 +127,7 @@
     tk-dev libgc-dev python-cffi \
     liblzma-dev libncursesw5-dev     # these two only needed on PyPy3
 
-On older Debian and Ubuntu (12.04 to 16.04)::
+On older Debian and Ubuntu (12.04-14.04)::
 
     apt-get install gcc make libffi-dev pkg-config libz-dev libbz2-dev \
     libsqlite3-dev libncurses-dev libexpat1-dev libssl-dev libgdbm-dev \
@@ -149,12 +149,23 @@
     xz-devel # For lzma on PyPy3.
     (XXX plus the SLES11 version of libgdbm-dev and tk-dev)
 
-On Mac OS X, most of these build-time dependencies are installed alongside
+On Mac OS X::
+
+Most of these build-time dependencies are installed alongside
 the Developer Tools. However, note that in order for the installation to
 find them you may need to run::
 
     xcode-select --install
 
+An exception is OpenSSL, which is no longer provided with the operating
+system. It can be obtained via Homebrew (with ``$ brew install openssl``),
+but it will not be available on the system path by default. The easiest
+way to enable it for building pypy is to set an environment variable::
+
+    export PKG_CONFIG_PATH=$(brew --prefix)/opt/openssl/lib/pkgconfig
+
+After setting this, translation (described next) will find the OpenSSL libs
+as expected.
 
 Run the translation
 -------------------
@@ -187,18 +198,18 @@
    entire pypy interpreter. This step is currently singe threaded, and RAM
    hungry. As part of this step,  the chain creates a large number of C code
    files and a Makefile to compile them in a
-   directory controlled by the ``PYPY_USESSION_DIR`` environment variable.  
+   directory controlled by the ``PYPY_USESSION_DIR`` environment variable.
 2. Create an executable ``pypy-c`` by running the Makefile. This step can
-   utilize all possible cores on the machine.  
-3. Copy the needed binaries to the current directory.  
-4. Generate c-extension modules for any cffi-based stdlib modules.  
+   utilize all possible cores on the machine.
+3. Copy the needed binaries to the current directory.
+4. Generate c-extension modules for any cffi-based stdlib modules.
 
 
 The resulting executable behaves mostly like a normal Python
 interpreter (see :doc:`cpython_differences`), and is ready for testing, for
 use as a base interpreter for a new virtualenv, or for packaging into a binary
 suitable for installation on another machine running the same OS as the build
-machine. 
+machine.
 
 Note that step 4 is merely done as a convenience, any of the steps may be rerun
 without rerunning the previous steps.
@@ -255,7 +266,7 @@
 
 * PyPy 2.5.1 or earlier: normal users would see permission errors.
   Installers need to run ``pypy -c "import gdbm"`` and other similar
-  commands at install time; the exact list is in 
+  commands at install time; the exact list is in
   :source:`pypy/tool/release/package.py <package.py>`.  Users
   seeing a broken installation of PyPy can fix it after-the-fact if they
   have sudo rights, by running once e.g. ``sudo pypy -c "import gdbm``.
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
@@ -240,9 +240,12 @@
 
 **matplotlib** https://github.com/matplotlib/matplotlib
 
-    TODO: the tkagg backend does not work, which makes tests fail on downstream
-    projects like Pandas, SciPy. It uses id(obj) as a c-pointer to obj in 
-    tkagg.py, which requires refactoring
+    Status: using the matplotlib branch of PyPy and the tkagg-cffi branch of
+    matplotlib from https://github.com/mattip/matplotlib/tree/tkagg-cffi, the
+    tkagg backend can function.
+
+    TODO: the matplotlib branch passes numpy arrays by value (copying all the
+    data), this proof-of-concept needs help to become completely compliant
 
 **wxPython** https://bitbucket.org/amauryfa/wxpython-cffi
 
diff --git a/pypy/doc/release-v5.9.0.rst b/pypy/doc/release-v5.9.0.rst
--- a/pypy/doc/release-v5.9.0.rst
+++ b/pypy/doc/release-v5.9.0.rst
@@ -10,15 +10,18 @@
 This new PyPy2.7 release includes the upstream stdlib version 2.7.13, and
 PyPy3.5 includes the upstream stdlib version 3.5.3.
 
-NumPy and Pandas now work on PyPy2.7. Issues that appeared as excessive memory
+NumPy and Pandas now work on PyPy2.7 (together with Cython 0.27.1). Issues
+that appeared as excessive memory
 use were cleared up and other incompatibilities were resolved. The C-API
 compatibility layer does slow down code which crosses the python-c interface
 often, we have ideas on how it could be improved, and still recommend
 using pure python on PyPy or interfacing via CFFI_. Many other modules
 based on C-API exentions now work on PyPy as well.
 
-Cython 0.27 (released last week) should support more projects with PyPy, both
-on PyPy2.7 and PyPy3.5 beta.
+Cython 0.27.1 (released very recently) supports more projects with PyPy, both
+on PyPy2.7 and PyPy3.5 beta. Note version **0.27.1** is now the minimum
+version that supports this version of PyPy, due to some interactions with
+updated C-API interface code.
 
 We optimized the JSON parser for recurring string keys, which should decrease
 memory use to 50% and increase parsing speed by up to 15% for large JSON files
@@ -148,8 +151,7 @@
   * Issue 2590_: fix the bounds in the GC when allocating a lot of objects 
with finalizers
   * Replace magical NOT RPYTHON comment with a decorator
   * Implement ``socket.sendmsg()``/``.recvmsg()`` for py3.5
-  * Reduce excessive ``memory_pressure`` for ``_SSLContext`` objects and add
-    ``memory_pressure`` for ``_SSLSocket`` objects
+  * Add ``memory_pressure`` for ``_SSLSocket`` objects
 
 * Degredations
 
diff --git a/pypy/doc/test/test_whatsnew.py b/pypy/doc/test/test_whatsnew.py
--- a/pypy/doc/test/test_whatsnew.py
+++ b/pypy/doc/test/test_whatsnew.py
@@ -89,7 +89,7 @@
     startrev, documented = parse_doc(last_whatsnew)
     merged, branch = get_merged_branches(ROOT, startrev, '')
     merged.discard('default')
-    merged.discard('py3k')
+    merged.discard('py3.5')
     merged.discard('')
     not_documented = merged.difference(documented)
     not_merged = documented.difference(merged)
@@ -100,7 +100,7 @@
     print '\n'.join(not_merged)
     print
     assert not not_documented
-    if branch == 'py3k':
+    if branch == 'py3.5':
         assert not not_merged
     else:
         assert branch in documented, 'Please document this branch before 
merging: %s' % branch
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
@@ -3,4 +3,10 @@
 ===========================
 
 .. this is a revision shortly after release-pypy2.7-v5.9.0
-.. startrev:899e5245de1e
+.. startrev:d56dadcef996
+
+.. branch: cppyy-packaging
+Cleanup and improve cppyy packaging
+
+.. branch: docs-osx-brew-openssl
+
diff --git a/pypy/doc/whatsnew-pypy2-5.9.0.rst 
b/pypy/doc/whatsnew-pypy2-5.9.0.rst
--- a/pypy/doc/whatsnew-pypy2-5.9.0.rst
+++ b/pypy/doc/whatsnew-pypy2-5.9.0.rst
@@ -85,3 +85,12 @@
 .. branch: py_ssize_t
 
 Explicitly use Py_ssize_t as the Signed type in pypy c-api
+
+.. branch: cpyext-jit
+
+Differentiate the code to call METH_NOARGS, METH_O and METH_VARARGS in cpyext:
+this allows to write specialized code which is much faster than previous
+completely generic version. Moreover, let the JIT to look inside the cpyext
+module: the net result is that cpyext calls are up to 7x faster. However, this
+is true only for very simple situations: in all real life code, we are still
+much slower than CPython (more optimizations to come)
diff --git a/pypy/doc/whatsnew-pypy3-head.rst b/pypy/doc/whatsnew-pypy3-head.rst
--- a/pypy/doc/whatsnew-pypy3-head.rst
+++ b/pypy/doc/whatsnew-pypy3-head.rst
@@ -5,7 +5,9 @@
 .. this is the revision after release-pypy3.5-5.9
 .. startrev: be41e3ac0a29
 
-.. branch: multiphase
+.. branch: sched_yield
+Add sched_yield posix attribute
 
-Implement PyType_FromSpec (PEP 384) and fix issues with PEP 489 support.
-
+.. branch: py3.5-appexec
+Raise if space.is_true(space.appexec()) used in app level tests, fix tests
+that did this
diff --git a/pypy/interpreter/test/test_app_main.py 
b/pypy/interpreter/test/test_app_main.py
--- a/pypy/interpreter/test/test_app_main.py
+++ b/pypy/interpreter/test/test_app_main.py
@@ -1162,9 +1162,13 @@
         import os
         old_sys_path = sys.path[:]
         sys.path.append(self.goal_dir)
+        if sys.platform == 'win32':
+            exename = 'pypy3-c.exe'
+        else:
+            exename = 'pypy3-c'
         try:
             import app_main
-            pypy_c = os.path.join(self.trunkdir, 'pypy', 'goal', 'pypy3-c')
+            pypy_c = os.path.join(self.trunkdir, 'pypy', 'goal', exename)
             app_main.setup_bootstrap_path(pypy_c)
             newpath = sys.path[:]
             # we get at least lib_pypy
@@ -1180,9 +1184,13 @@
         import os
         old_sys_path = sys.path[:]
         sys.path.append(self.goal_dir)
+        if sys.platform == 'win32':
+            exename = 'pypy3-c.exe'
+        else:
+            exename = 'pypy3-c'
         try:
             import app_main
-            pypy_c = os.path.join(self.trunkdir, 'pypy', 'goal', 'pypy3-c')
+            pypy_c = os.path.join(self.trunkdir, 'pypy', 'goal', exename)
             app_main.entry_point(pypy_c, [self.foo_py])
             # assert it did not crash
         finally:
diff --git a/pypy/interpreter/test/test_interpreter.py 
b/pypy/interpreter/test/test_interpreter.py
--- a/pypy/interpreter/test/test_interpreter.py
+++ b/pypy/interpreter/test/test_interpreter.py
@@ -1,7 +1,6 @@
 import py 
 import sys
 from pypy.interpreter import gateway, module, error
-from hypothesis import given, strategies
 
 class TestInterpreter: 
 
@@ -300,30 +299,6 @@
         assert "TypeError:" in res
         assert "'tuple' object is not a mapping" in res
 
-    @given(strategies.lists(strategies.one_of(strategies.none(),
-                                 strategies.lists(strategies.none()))))
-    def test_build_map_order(self, shape):
-        value = [10]
-        def build_expr(shape):
-            if shape is None:
-                value[0] += 1
-                return '0: %d' % value[0]
-            else:
-                return '**{%s}' % (', '.join(
-                    [build_expr(shape1) for shape1 in shape]),)
-
-        expr = build_expr(shape)[2:]
-        code = """
-        def f():
-            return %s
-        """ % (expr, )
-        res = self.codetest(code, 'f', [])
-        if value[0] == 10:
-            expected = {}
-        else:
-            expected = {0: value[0]}
-        assert res == expected, "got %r for %r" % (res, expr)
-
     def test_build_map_unpack_with_call(self):
         code = """
         def f(a,b,c,d):
@@ -348,6 +323,36 @@
         assert "TypeError:" in resg4
         assert "got multiple values for keyword argument 'a'" in resg4
 
+try:
+    from hypothesis import given, strategies
+except ImportError:
+    pass
+else:
+    class TestHypothesisInterpreter(TestInterpreter): 
+        @given(strategies.lists(strategies.one_of(strategies.none(),
+                                     strategies.lists(strategies.none()))))
+        def test_build_map_order(self, shape):
+            value = [10]
+            def build_expr(shape):
+                if shape is None:
+                    value[0] += 1
+                    return '0: %d' % value[0]
+                else:
+                    return '**{%s}' % (', '.join(
+                        [build_expr(shape1) for shape1 in shape]),)
+
+            expr = build_expr(shape)[2:]
+            code = """
+            def f():
+                return %s
+            """ % (expr, )
+            res = self.codetest(code, 'f', [])
+            if value[0] == 10:
+                expected = {}
+            else:
+                expected = {0: value[0]}
+            assert res == expected, "got %r for %r" % (res, expr)
+
 
 class AppTestInterpreter: 
     def test_trivial(self):
diff --git a/pypy/module/__builtin__/test/test_descriptor.py 
b/pypy/module/__builtin__/test/test_descriptor.py
--- a/pypy/module/__builtin__/test/test_descriptor.py
+++ b/pypy/module/__builtin__/test/test_descriptor.py
@@ -258,6 +258,17 @@
         raises(TypeError, "super(D).__get__(12)")
         raises(TypeError, "super(D).__get__(C())")
 
+    def test_super_incomplete(self):
+        """
+        class M(type):
+            def mro(cls):
+                if cls.__mro__ is None:
+                    raises(AttributeError, lambda: super(cls, cls).xxx)
+                return type.mro(cls)
+        class A(metaclass=M):
+            pass
+        """
+
     def test_classmethods_various(self):
         class C(object):
             def foo(*a): return a
diff --git a/pypy/module/_cffi_backend/__init__.py 
b/pypy/module/_cffi_backend/__init__.py
--- a/pypy/module/_cffi_backend/__init__.py
+++ b/pypy/module/_cffi_backend/__init__.py
@@ -3,7 +3,7 @@
 from rpython.rlib import rdynload, clibffi
 from rpython.rtyper.lltypesystem import rffi
 
-VERSION = "1.11.1"
+VERSION = "1.11.2"
 
 FFI_DEFAULT_ABI = clibffi.FFI_DEFAULT_ABI
 try:
diff --git a/pypy/module/_cffi_backend/cffi1_module.py 
b/pypy/module/_cffi_backend/cffi1_module.py
--- a/pypy/module/_cffi_backend/cffi1_module.py
+++ b/pypy/module/_cffi_backend/cffi1_module.py
@@ -1,4 +1,5 @@
 from rpython.rtyper.lltypesystem import lltype, rffi
+from rpython.rlib import jit
 
 from pypy.interpreter.error import oefmt
 from pypy.interpreter.module import Module
@@ -15,7 +16,7 @@
 
 INITFUNCPTR = lltype.Ptr(lltype.FuncType([rffi.VOIDPP], lltype.Void))
 
-
+@jit.dont_look_inside
 def load_cffi1_module(space, name, path, initptr):
     # This is called from pypy.module.cpyext.api.load_extension_module()
     from pypy.module._cffi_backend.call_python import get_ll_cffi_call_python
diff --git a/pypy/module/_cffi_backend/ctypeptr.py 
b/pypy/module/_cffi_backend/ctypeptr.py
--- a/pypy/module/_cffi_backend/ctypeptr.py
+++ b/pypy/module/_cffi_backend/ctypeptr.py
@@ -158,10 +158,11 @@
 
 class W_CTypePtrBase(W_CTypePtrOrArray):
     # base class for both pointers and pointers-to-functions
-    _attrs_ = ['is_void_ptr', 'is_voidchar_ptr']
-    _immutable_fields_ = ['is_void_ptr', 'is_voidchar_ptr']
+    _attrs_ = ['is_void_ptr', 'is_voidchar_ptr', 'is_onebyte_ptr']
+    _immutable_fields_ = ['is_void_ptr', 'is_voidchar_ptr', 'is_onebyte_ptr']
     is_void_ptr = False
     is_voidchar_ptr = False
+    is_onebyte_ptr = False
 
     def convert_to_object(self, cdata):
         ptrdata = rffi.cast(rffi.CCHARPP, cdata)[0]
@@ -181,12 +182,20 @@
             if self.is_void_ptr or other.is_void_ptr:
                 pass     # cast from or to 'void *'
             elif self.is_voidchar_ptr or other.is_voidchar_ptr:
-                space = self.space
-                msg = ("implicit cast from '%s' to '%s' "
-                    "will be forbidden in the future (check that the types "
-                    "are as you expect; use an explicit ffi.cast() if they "
-                    "are correct)" % (other.name, self.name))
-                space.warn(space.newtext(msg), space.w_UserWarning)
+                # for backward compatibility, accept "char *" as either
+                # source of target.  This is not what C does, though,
+                # so emit a warning that will eventually turn into an
+                # error.  The warning is turned off if both types are
+                # pointers to single bytes.
+                if self.is_onebyte_ptr and other.is_onebyte_ptr:
+                    pass   # no warning
+                else:
+                    space = self.space
+                    msg = ("implicit cast from '%s' to '%s' "
+                        "will be forbidden in the future (check that the types 
"
+                        "are as you expect; use an explicit ffi.cast() if they 
"
+                        "are correct)" % (other.name, self.name))
+                    space.warn(space.newtext(msg), space.w_UserWarning)
             else:
                 raise self._convert_error("compatible pointer", w_ob)
 
@@ -216,6 +225,7 @@
         self.is_void_ptr = isinstance(ctitem, ctypevoid.W_CTypeVoid)
         self.is_voidchar_ptr = (self.is_void_ptr or
                            isinstance(ctitem, ctypeprim.W_CTypePrimitiveChar))
+        self.is_onebyte_ptr = (ctitem.size == 1)
         W_CTypePtrBase.__init__(self, space, size, extra, 2, ctitem)
 
     def newp(self, w_init, allocator):
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py 
b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -1,7 +1,7 @@
 # ____________________________________________________________
 
 import sys
-assert __version__ == "1.11.1", ("This test_c.py file is for testing a version"
+assert __version__ == "1.11.2", ("This test_c.py file is for testing a version"
                                  " of cffi that differs from the one that we"
                                  " get from 'import _cffi_backend'")
 if sys.version_info < (3,):
@@ -2099,7 +2099,8 @@
     if sys.platform.startswith("linux"):
         BWChar = new_primitive_type("wchar_t")
         assert sizeof(BWChar) == 4
-        assert int(cast(BWChar, -1)) == -1        # signed, on linux
+        # wchar_t is often signed on Linux, but not always (e.g. on ARM)
+        assert int(cast(BWChar, -1)) in (-1, 4294967295)
 
 def test_char16():
     BChar16 = new_primitive_type("char16_t")
@@ -3903,9 +3904,11 @@
     BCharP = new_pointer_type(new_primitive_type("char"))
     BIntP = new_pointer_type(new_primitive_type("int"))
     BVoidP = new_pointer_type(new_void_type())
+    BUCharP = new_pointer_type(new_primitive_type("unsigned char"))
     z1 = cast(BCharP, 0)
     z2 = cast(BIntP, 0)
     z3 = cast(BVoidP, 0)
+    z4 = cast(BUCharP, 0)
     with warnings.catch_warnings(record=True) as w:
         newp(new_pointer_type(BIntP), z1)    # warn
         assert len(w) == 1
@@ -3919,6 +3922,12 @@
         assert len(w) == 2
         newp(new_pointer_type(BIntP), z3)    # fine
         assert len(w) == 2
+        newp(new_pointer_type(BCharP), z4)   # fine (ignore signedness here)
+        assert len(w) == 2
+        newp(new_pointer_type(BUCharP), z1)  # fine (ignore signedness here)
+        assert len(w) == 2
+        newp(new_pointer_type(BUCharP), z3)  # fine
+        assert len(w) == 2
     # check that the warnings are associated with lines in this file
     assert w[1].lineno == w[0].lineno + 4
 
diff --git a/pypy/module/_codecs/test/test_codecs.py 
b/pypy/module/_codecs/test/test_codecs.py
--- a/pypy/module/_codecs/test/test_codecs.py
+++ b/pypy/module/_codecs/test/test_codecs.py
@@ -762,9 +762,16 @@
         assert s == b'\xe9'
 
     def test_lone_surrogates(self):
-        for encoding in ('utf-8', 'utf-16', 'utf-16-le', 'utf-16-be',
-                         'utf-32', 'utf-32-le', 'utf-32-be'):
+        encodings = ('utf-8', 'utf-16', 'utf-16-le', 'utf-16-be',
+            'utf-32', 'utf-32-le', 'utf-32-be')
+        for encoding in encodings:
             raises(UnicodeEncodeError, u'\ud800'.encode, encoding)
+            assert (u'[\udc80]'.encode(encoding, "backslashreplace") ==
+                '[\\udc80]'.encode(encoding))
+            assert (u'[\udc80]'.encode(encoding, "ignore") ==
+                '[]'.encode(encoding))
+            assert (u'[\udc80]'.encode(encoding, "replace") ==
+                '[?]'.encode(encoding))
 
     def test_charmap_encode(self):
         assert 'xxx'.encode('charmap') == b'xxx'
diff --git a/pypy/module/_continuation/test/test_stacklet.py 
b/pypy/module/_continuation/test/test_stacklet.py
--- a/pypy/module/_continuation/test/test_stacklet.py
+++ b/pypy/module/_continuation/test/test_stacklet.py
@@ -290,66 +290,87 @@
     def test_random_switching(self):
         from _continuation import continulet
         #
+        seen = []
+        #
         def t1(c1):
-            return c1.switch()
+            seen.append(3)
+            res = c1.switch()
+            seen.append(6)
+            return res
+        #
         def s1(c1, n):
+            seen.append(2)
             assert n == 123
             c2 = t1(c1)
-            return c1.switch('a') + 1
+            seen.append(7)
+            res = c1.switch('a') + 1
+            seen.append(10)
+            return res
         #
         def s2(c2, c1):
+            seen.append(5)
             res = c1.switch(c2)
+            seen.append(8)
             assert res == 'a'
-            return c2.switch('b') + 2
+            res = c2.switch('b') + 2
+            seen.append(12)
+            return res
         #
         def f():
+            seen.append(1)
             c1 = continulet(s1, 123)
             c2 = continulet(s2, c1)
             c1.switch()
+            seen.append(4)
             res = c2.switch()
+            seen.append(9)
             assert res == 'b'
             res = c1.switch(1000)
+            seen.append(11)
             assert res == 1001
-            return c2.switch(2000)
+            res = c2.switch(2000)
+            seen.append(13)
+            return res
         #
         res = f()
         assert res == 2002
+        assert seen == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
 
     def test_f_back(self):
         import sys
         from _continuation import continulet
         #
-        def g(c):
+        def bar(c):
             c.switch(sys._getframe(0))
             c.switch(sys._getframe(0).f_back)
             c.switch(sys._getframe(1))
             c.switch(sys._getframe(1).f_back)
-            assert sys._getframe(2) is f3.f_back
+            assert sys._getframe(2) is f3_foo.f_back
             c.switch(sys._getframe(2))
-        def f(c):
-            g(c)
+        def foo(c):
+            bar(c)
         #
-        c = continulet(f)
-        f1 = c.switch()
-        assert f1.f_code.co_name == 'g'
-        f2 = c.switch()
-        assert f2.f_code.co_name == 'f'
-        f3 = c.switch()
-        assert f3 is f2
-        assert f1.f_back is f3
+        c = continulet(foo)
+        f1_bar = c.switch()
+        assert f1_bar.f_code.co_name == 'bar'
+        f2_foo = c.switch()
+        assert f2_foo.f_code.co_name == 'foo'
+        f3_foo = c.switch()
+        assert f3_foo is f2_foo
+        assert f1_bar.f_back is f3_foo
         def main():
-            f4 = c.switch()
-            assert f4.f_code.co_name == 'main', repr(f4.f_code.co_name)
-            assert f3.f_back is f1    # not running, so a loop
+            f4_main = c.switch()
+            assert f4_main.f_code.co_name == 'main'
+            assert f3_foo.f_back is f1_bar    # not running, so a loop
         def main2():
-            f5 = c.switch()
-            assert f5.f_code.co_name == 'main2', repr(f5.f_code.co_name)
-            assert f3.f_back is f1    # not running, so a loop
+            f5_main2 = c.switch()
+            assert f5_main2.f_code.co_name == 'main2'
+            assert f3_foo.f_back is f1_bar    # not running, so a loop
         main()
         main2()
         res = c.switch()
         assert res is None
-        assert f3.f_back is None
+        assert f3_foo.f_back is None
 
     def test_traceback_is_complete(self):
         import sys
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
@@ -1,12 +1,10 @@
 from pypy.interpreter.mixedmodule import MixedModule
 
 class Module(MixedModule):
-    "This module provides runtime bindings to C++ code for which reflection\n\
-    info has been generated. Current supported back-ends are Reflex and 
CINT.\n\
-    See http://doc.pypy.org/en/latest/cppyy.html for full details."
+    "This module brigdes the cppyy frontend with its backend, through PyPy.\n\
+    See http://cppyy.readthedocs.io/en/latest for full details."
 
     interpleveldefs = {
-        '_load_dictionary'       : 'interp_cppyy.load_dictionary',
         '_resolve_name'          : 'interp_cppyy.resolve_name',
         '_scope_byname'          : 'interp_cppyy.scope_byname',
         '_template_byname'       : 'interp_cppyy.template_byname',
@@ -15,14 +13,13 @@
         '_set_function_generator': 'interp_cppyy.set_function_generator',
         '_register_class'        : 'interp_cppyy.register_class',
         '_get_nullptr'           : 'interp_cppyy.get_nullptr',
-        'CPPInstanceBase'        : 'interp_cppyy.W_CPPInstance',
+        'CPPClassBase'           : 'interp_cppyy.W_CPPClass',
         'addressof'              : 'interp_cppyy.addressof',
         'bind_object'            : 'interp_cppyy.bind_object',
     }
 
     appleveldefs = {
         '_init_pythonify'        : 'pythonify._init_pythonify',
-        'load_reflection_info'   : 'pythonify.load_reflection_info',
         'add_pythonization'      : 'pythonify.add_pythonization',
         'Template'               : 'pythonify.CPPTemplate',
     }
diff --git a/pypy/module/_cppyy/backend/create_cppyy_package.py 
b/pypy/module/_cppyy/backend/create_cppyy_package.py
deleted file mode 100755
--- a/pypy/module/_cppyy/backend/create_cppyy_package.py
+++ /dev/null
@@ -1,649 +0,0 @@
-#!/usr/bin/env python
-from __future__ import print_function
-
-import os, sys
-import argparse, re, shutil, tarfile, urllib2
-
-
-DEBUG_TESTBUILD = False
-
-TARBALL_CACHE_DIR = 'releases'
-
-ROOT_KEEP = ['build', 'cmake', 'config', 'core', 'etc', 'interpreter',
-             'io', 'LICENSE', 'net', 'Makefile', 'CMakeLists.txt', 'math',
-             'main'] # main only needed in more recent root b/c of rootcling
-ROOT_CORE_KEEP = ['CMakeLists.txt', 'base', 'clib', 'clingutils', 'cont',
-                  'dictgen', 'foundation', 'lzma', 'macosx', 'meta',
-                  'metacling', 'metautils', 'rootcling_stage1', 'textinput',
-                  'thread', 'unix', 'utils', 'winnt', 'zip']
-ROOT_IO_KEEP = ['CMakeLists.txt', 'io', 'rootpcm']
-ROOT_NET_KEEP = ['CMakeLists.txt', 'net']
-ROOT_MATH_KEEP = ['CMakeLists.txt', 'mathcore']
-ROOT_ETC_KEEP = ['Makefile.arch', 'class.rules', 'cmake', 'dictpch',
-                 'gdb-backtrace.sh', 'gitinfo.txt', 'helgrind-root.supp',
-                 'hostcert.conf', 'system.plugins-ios',
-                 'valgrind-root-python.supp', 'valgrind-root.supp', 'vmc']
-
-ROOT_EXPLICIT_REMOVE = ['core/base/v7', 'math/mathcore/v7', 'io/io/v7']
-
-
-ERR_RELEASE_NOT_FOUND = 2
-
-
-#
-## CLI arguments
-#
-class ReleaseValidation(argparse.Action):
-    def __call__(self, parser, namespace, value, option_string=None):
-        if not re.match(r'6\.\d\d\.\d\d', value):
-            raise argparse.ArgumentTypeError(
-                "release number should of the form '6.dd.dd'")
-        setattr(namespace, self.dest, value)
-        return value
-
-parser = argparse.ArgumentParser(
-    description='Build PyPi package for cppyy containing the minimum of ROOT')
-parser.add_argument('-r', '--release', type=str, nargs='?',
-                    action=ReleaseValidation, help='ROOT release to use')
-
-args = parser.parse_args()
-
-
-#
-## ROOT source pull and cleansing
-#
-def clean_directory(directory, keeplist, trim_cmake=True):
-    removed_entries = []
-    for entry in os.listdir(directory):
-        if entry[0] == '.' or entry in keeplist:
-            continue
-        removed_entries.append(entry)
-        entry = os.path.join(directory, entry)
-        print('now removing', entry)
-        if os.path.isdir(entry):
-            shutil.rmtree(entry)
-        else:
-            os.remove(entry)
-
-    if not trim_cmake:
-        return
-
-    # now take the removed entries out of the CMakeLists.txt
-    if removed_entries:
-        inp = os.path.join(directory, 'CMakeLists.txt')
-        print('trimming', inp)
-        outp = inp+'.new'
-        new_cml = open(outp, 'w')
-        for line in open(inp).readlines():
-            if ('add_subdirectory' in line) or\
-               ('COMMAND' in line and 'copy' in line) or\
-               ('ROOT_ADD_TEST_SUBDIRECTORY' in line) or\
-               ('install(DIRECTORY' in line):
-                for sub in removed_entries:
-                    if sub in line:
-                        line = '#'+line
-                        break
-            new_cml.write(line)
-        new_cml.close()
-        os.rename(outp, inp)
-    else:
-        print('reusing existing %s/CMakeLists.txt' % (directory,))
- 
-
-class ReleaseValidation(argparse.Action):
-    def __call__(self, parser, namespace, value, option_string=None):
-        if not re.match(r'6\.\d\d\.\d\d', value):
-            raise argparse.ArgumentTypeError(
-                "release number should of the form '6.dd.dd'")
-        setattr(namespace, self.dest, value)
-        return value
-
-parser = argparse.ArgumentParser(
-    description='Build PyPi package for cppyy containing the minimum of ROOT')
-parser.add_argument('-r', '--release', type=str, nargs='?',
-                    action=ReleaseValidation, help='ROOT release to use')
-
-args = parser.parse_args()
-
-if not os.path.exists(TARBALL_CACHE_DIR):
-    os.mkdir(TARBALL_CACHE_DIR)
-
-if args.release:
-  # use provided release
-    fn = 'root_v%s.source.tar.gz' % args.release
-    addr = 'https://root.cern.ch/download/'+fn
-    if not os.path.exists(os.path.join(TARBALL_CACHE_DIR, fn)):
-        try:
-            print('retrieving', fn)
-            resp = urllib2.urlopen(addr, fn)
-            out = open(os.path.join(TARBALL_CACHE_DIR, fn), 'wb')
-            out.write(resp.read())
-            out.close()
-        except urllib2.HTTPError:
-            print('release %s not found' % args.release)
-            sys.exit(ERR_RELEASE_NOT_FOUND)
-    else:
-        print('reusing', fn, 'from local directory')
-else:
-    print('provide release ... getting latest release is not yet implemented 
...')
-    sys.exit(1)
-  # get latest and set fn, args.release, etc.
-
-# construct version for package
-args.version = ''
-testnext = False
-for c in args.release:
-    if testnext:
-        testnext = False
-        if c == '0':
-            continue
-    if c == '.':
-        testnext = True
-    args.version += c
-args.version += '.0'
-
-fn = os.path.join(TARBALL_CACHE_DIR, fn)
-pkgdir = os.path.join('root-'+args.release)
-if not os.path.exists(pkgdir):
-    print('now extracting', args.release)
-    tf = tarfile.TarFile.gzopen(fn)
-    tf.extractall()
-    tf.close()
-else:
-    print('reusing existing directory', pkgdir)
-
-# remove everything except for the listed set of libraries
-os.chdir(pkgdir)
-
-clean_directory(os.path.curdir, ROOT_KEEP)
-clean_directory('core',         ROOT_CORE_KEEP)
-clean_directory('etc',          ROOT_ETC_KEEP, trim_cmake=False)
-clean_directory('io',           ROOT_IO_KEEP)
-clean_directory('math',         ROOT_MATH_KEEP)
-clean_directory('net',          ROOT_NET_KEEP)
-
-
-# trim main (only need rootcling)
-print('trimming main')
-for entry in os.listdir('main/src'):
-    if entry != 'rootcling.cxx':
-        os.remove('main/src/'+entry)
-inp = 'main/CMakeLists.txt'
-outp = inp+'.new'
-new_cml = open(outp, 'w')
-for line in open(inp).readlines():
-    if ('ROOT_EXECUTABLE' in line or\
-        'SET_TARGET_PROPERTIES' in line) and\
-       not 'rootcling' in line:
-        line = '#'+line
-    new_cml.write(line)
-new_cml.close()
-os.rename(outp, inp)
-
-
-# remove afterimage and ftgl explicitly
-print('trimming externals')
-for cmf in ['AfterImage', 'FTGL']:
-    os.remove('cmake/modules/Find%s.cmake' % (cmf,))
-inp = 'cmake/modules/SearchInstalledSoftware.cmake'
-outp = inp+'.new'
-now_stripping = False
-new_cml = open(outp, 'w')
-for line in open(inp).readlines():
-    if '#---Check for ftgl if needed' == line[0:28] or\
-       '#---Check for AfterImage' == line[0:24]:
-        now_stripping = True
-    elif '#---Check' == line[0:9]:
-        now_stripping = False
-    if now_stripping:
-        line = '#'+line
-    new_cml.write(line)
-new_cml.close()
-os.rename(outp, inp)
-
-inp = 'cmake/modules/RootBuildOptions.cmake'
-outp = inp+'.new'
-new_cml = open(outp, 'w')
-for line in open(inp).readlines():
-    if 'ROOT_BUILD_OPTION(builtin_ftgl' in line or\
-       'ROOT_BUILD_OPTION(builtin_afterimage' in line:
-        line = '#'+line
-    new_cml.write(line)
-new_cml.close()
-os.rename(outp, inp)
-
-
-# remove testing and examples
-print('trimming testing')
-inp = 'CMakeLists.txt'
-outp = inp+'.new'
-now_stripping = False
-new_cml = open(outp, 'w')
-for line in open(inp).readlines():
-    if '#---Configure Testing using CTest' == line[0:33] or\
-       '#---hsimple.root' == line[0:16]:
-        now_stripping = True
-    elif '#---Packaging' == line[0:13] or\
-         '#---version' == line[0:11]:
-        now_stripping = False
-    if now_stripping:
-        line = '#'+line
-    new_cml.write(line)
-new_cml.close()
-os.rename(outp, inp)
-
-print('trimming RootCPack')
-inp = 'cmake/modules/RootCPack.cmake'
-outp = inp+'.new'
-new_cml = open(outp, 'w')
-for line in open(inp):
-    if 'README.txt' in line:
-        line = '#'+line
-    new_cml.write(line)
-new_cml.close()
-os.rename(outp, inp)
-
-# some more explicit removes:
-for dir_to_remove in ROOT_EXPLICIT_REMOVE:
-    try:
-        shutil.rmtree(dir_to_remove)
-    except OSError:
-        pass
-
-# special fixes
-inp = 'core/base/src/TVirtualPad.cxx'
-outp = inp+'.new'
-new_cml = open(outp, 'w')
-for line in open(inp):
-    if '#include "X3DBuffer.h"' == line[0:22]:
-        line = """//#include "X3DBuffer.h"
-typedef struct _x3d_sizeof_ {
-   int  numPoints;
-   int  numSegs;
-   int  numPolys;
-} Size3D;
-"""
-    new_cml.write(line)
-new_cml.close()
-os.rename(outp, inp)
-
-inp = 'math/mathcore/src/Fitter.cxx'
-if os.path.exists(inp):
-    outp = inp+'.new'
-    new_cml = open(outp, 'w')
-    for line in open(inp):
-        if '#include "TF1.h"' in line:
-            continue
-        new_cml.write(line)
-    new_cml.close()
-    os.rename(outp, inp)
-
-# done
-os.chdir(os.path.pardir)
-
-# debugging: run a test build
-if DEBUG_TESTBUILD:
-    print('running a debug test build')
-    tb = "test_builddir"
-    if os.path.exists(tb):
-        shutil.rmtree(tb)
-    os.mkdir(tb)
-    os.chdir(tb)
-    os.system('cmake ../%s -DCMAKE_INSTALL_PREFIX=../install -Dminimal=ON 
-Dasimage=OFF' % pkgdir)
-    os.system('make -j 32')
-
-
-#
-## package creation
-#
-countdown = 0
-pidir = 'Package-'+args.release
-print('creating package', pidir)
-if not os.path.exists(pidir):
-    os.mkdir(pidir)
-os.chdir(pidir); countdown += 1
-
-print('creating LICENSE.txt')
-with open('LICENSE.txt', 'w') as outp:
-    outp.write("""There are three main parts:
-
- LLVM: distributed under University of Illinois/NCSA Open Source License
-   https://opensource.org/licenses/UoI-NCSA.php
- ROOT: distributed under LGPL 2.1
-   https://root.cern.ch/license
- Cppyy: distributed under LBNL BSD
-   https://fedoraproject.org/wiki/Licensing/LBNLBSD
-""")
-
-print('creating MANIFEST.in')
-with open('MANIFEST.in', 'w') as outp:
-    outp.write("""# Include the license file
-include LICENSE.txt
-
-# Include the data files
-recursive-include src *
-""")
-
-print('creating README.rst')
-with open('README.rst', 'w') as outp:
-    outp.write("""PyPy cling-support
-==================
-
-----
-
-Find the documentation here:
-  http://doc.pypy.org/en/latest/cppyy.html
-""")
-
-print('creating setup.cfg')
-with open('setup.cfg', 'w') as outp:
-    outp.write("""[bdist_wheel]
-universal=0
-""")
-
-print('creating setup.py')
-with open('setup.py', 'w') as outp:
-    outp.write("""import os, sys, subprocess
-from setuptools import setup, find_packages
-from distutils import log
-from distutils.command.build import build as _build
-from setuptools.command.install import install as _install
-from distutils.sysconfig import get_python_lib
-from distutils.errors import DistutilsSetupError
-from codecs import open
-
-here = os.path.abspath(os.path.dirname(__file__))
-with open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
-    long_description = f.read()
-
-builddir = None
-def get_builddir():
-    global builddir
-    if builddir is None:
-        topdir = os.getcwd()
-        builddir = os.path.join(topdir, 'builddir')
-    return builddir
-
-srcdir = None
-def get_srcdir():
-    global srcdir
-    if srcdir is None:
-        topdir = os.getcwd()
-        srcdir = os.path.join(topdir, 'src', 'backend')
-    return srcdir
-
-class my_cmake_build(_build):
-    def __init__(self, dist, *args, **kwargs):
-        _build.__init__(self, dist, *args, **kwargs)
-        # TODO: can't seem to find a better way of getting hold of
-        # the install_lib parameter during the build phase ...
-        prefix = ''
-        try:
-            prefix = dist.get_command_obj('install').install_lib
-        except AttributeError:
-            pass
-        if not prefix:
-            prefix = get_python_lib(1, 0)
-        self.prefix = os.path.join(prefix, 'cppyy_backend')
-
-    def run(self):
-        # base run
-        _build.run(self)
-
-        # custom run
-        log.info('Now building libcppyy_backend.so and dependencies')
-        builddir = get_builddir()
-        srcdir = get_srcdir()
-        if not os.path.exists(builddir):
-            log.info('Creating build directory %s ...' % builddir)
-            os.makedirs(builddir)
-
-        os.chdir(builddir)
-        log.info('Running cmake for cppyy_backend')
-        if subprocess.call([
-                'cmake', srcdir, '-Dminimal=ON -Dasimage=OFF',
-                '-DCMAKE_INSTALL_PREFIX='+self.prefix]) != 0:
-            raise DistutilsSetupError('Failed to configure cppyy_backend')
-
-        nprocs = os.getenv("MAKE_NPROCS")
-        if nprocs:
-            try:
-                ival = int(nprocs)
-                nprocs = '-j'+nprocs
-            except ValueError:
-                log.warn("Integer expected for MAKE_NPROCS, but got %s 
(ignored)", nprocs)
-                nprocs = '-j1'
-        else:
-            nprocs = '-j1'
-        log.info('Now building cppyy_backend and dependencies ...')
-        if subprocess.call(['make', nprocs]) != 0:
-            raise DistutilsSetupError('Failed to build cppyy_backend')
-
-        log.info('build finished')
-
-class my_libs_install(_install):
-    def run(self):
-        # base install
-        _install.run(self)
-
-        # custom install
-        log.info('Now installing libcppyy_backend.so and dependencies')
-        builddir = get_builddir()
-        if not os.path.exists(builddir):
-            raise DistutilsSetupError('Failed to find build dir!')
-        os.chdir(builddir)
-
-        prefix = self.install_lib
-        log.info('Now installing in %s ...', prefix)
-        if subprocess.call(['make', 'install']) != 0:
-            raise DistutilsSetupError('Failed to install cppyy_backend')
-
-        log.info('install finished')
-
-    def get_outputs(self):
-        outputs = _install.get_outputs(self)
-        outputs.append(os.path.join(self.install_lib, 'cppyy_backend'))
-        return outputs
-
-setup(
-    name='PyPy-cppyy-backend',
-""")
-    outp.write("    version='%s', # corresponds to ROOT %s, extra number is 
for packager\n"\
-         % (args.version, args.release))
-    outp.write("""    description='Cling support for PyPy',
-    long_description=long_description,
-
-    url='http://pypy.org',
-
-    # Author details
-    author='PyPy Developers',
-    author_email='pypy-...@python.org',
-
-    license='LLVM: UoI-NCSA; ROOT: LGPL 2.1; Cppyy: LBNL BSD',
-
-    classifiers=[
-        'Development Status :: 4 - Beta',
-
-        'Intended Audience :: Developers',
-
-        'Topic :: Software Development',
-        'Topic :: Software Development :: Interpreters',
-
-        #'License :: OSI Approved :: MIT License',
-
-        'Programming Language :: Python :: 2',
-        'Programming Language :: Python :: 2.7',
-        'Programming Language :: Python :: Implementation :: PyPy',
-        'Programming Language :: C',
-        'Programming Language :: C++',
-
-        'Natural Language :: English'
-    ],
-
-    keywords='interpreter development',
-
-    packages=find_packages('src', ['backend']),
-    include_package_data=True,
-
-    extras_require={
-    },
-
-    cmdclass = {
-        'build': my_cmake_build,
-        'install': my_libs_install,
-    },
-)
-""")
-
-
-print('creating src ... ROOT part')
-if not os.path.exists('src'):
-    os.mkdir('src')
-os.chdir('src'); countdown += 1
-if not os.path.exists('backend'):
-    src = os.path.join(os.path.pardir, os.path.pardir, pkgdir)
-    print('now copying', src)
-    shutil.copytree(src, 'backend')
-
-print('creating src ... cppyy part')
-os.chdir('backend'); countdown += 1
-if not os.path.exists('cppyy'):
-    os.mkdir('cppyy')
-    os.chdir('cppyy'); countdown += 1
-
-    with open('CMakeLists.txt', 'w') as outp:
-        
outp.write("""############################################################################
-# CMakeLists.txt file for building cppyy package
-############################################################################
-
-ROOT_GLOB_SOURCES(sources ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cxx)
-set_source_files_properties(${sources} COMPILE_FLAGS "-fomit-frame-pointer 
-fvisibility=hidden -DRPY_EXTERN=RPY_EXPORTED -DRPYTHON_LL2CTYPES")
-
-add_definitions(${CLING_CXXFLAGS})
-
-ROOT_LINKER_LIBRARY(cppyy_backend ${sources}
-                               LIBRARIES ${CMAKE_DL_LIBS}
-                               DEPENDENCIES Core Cling RIO Thread)
-
-add_dependencies(cppyy_backend CLING)
-""")
-
-    os.mkdir('src')
-    os.chdir('src'); countdown += 1
-    print('pulling cppyy/clingcwrapper.cxx from pypy')
-    base = 'https://bitbucket.org/pypy/pypy/raw/default/pypy/module/cppyy/'
-    for cppyy_file in ['src/callcontext.h', 'include/capi.h', 
'src/clingcwrapper.cxx',
-                       'include/clingcwrapper.h', 'include/cpp_cppyy.h', 
'include/cppyy.h']:
-        resp = urllib2.urlopen(base+cppyy_file)
-        with open(os.path.basename(cppyy_file), 'w') as outp:
-            outp.write(resp.read())
-
-    # fix include
-    inp = 'capi.h'
-    outp = inp+'.new'
-    new_cml = open(outp, 'w')
-    for line in open(inp).readlines():
-        if 'src/precommondefs.h' in line:
-            line = '#include "precommondefs.h"\n'
-        new_cml.write(line)
-    new_cml.close()
-    os.rename(outp, inp)
-
-    with open('precommondefs.h', 'w') as outp:
-        outp.write("""/***** Start of precommondefs.h *****/
-
-/* This is extracted from pyconfig.h from CPython.  It sets the macros
-   that affect the features we get from system include files.
-   It must not #include anything. */
-
-#ifndef __PYPY_PRECOMMONDEFS_H
-#define __PYPY_PRECOMMONDEFS_H
-
-
-/* Define on Darwin to activate all library features */
-#define _DARWIN_C_SOURCE 1
-/* This must be set to 64 on some systems to enable large file support. */
-#define _FILE_OFFSET_BITS 64
-/* Define on Linux to activate all library features */
-#define _GNU_SOURCE 1
-/* This must be defined on some systems to enable large file support. */
-#define _LARGEFILE_SOURCE 1
-/* Define on NetBSD to activate all library features */
-#define _NETBSD_SOURCE 1
-/* Define to activate features from IEEE Stds 1003.1-2001 */
-#ifndef _POSIX_C_SOURCE
-#  define _POSIX_C_SOURCE 200112L
-#endif
-/* Define on FreeBSD to activate all library features */
-#define __BSD_VISIBLE 1
-#define __XSI_VISIBLE 700
-/* Windows: winsock/winsock2 mess */
-#define WIN32_LEAN_AND_MEAN
-#ifdef _WIN64
-   typedef          __int64 Signed;
-   typedef unsigned __int64 Unsigned;
-#  define SIGNED_MIN LLONG_MIN
-#else
-   typedef          long Signed;
-   typedef unsigned long Unsigned;
-#  define SIGNED_MIN LONG_MIN
-#endif
-
-#if !defined(RPY_ASSERT) && !defined(RPY_LL_ASSERT) && !defined(NDEBUG)
-#  define NDEBUG
-#endif
-
-
-/* All functions and global variables declared anywhere should use
-   one of the following attributes:
-
-   RPY_EXPORTED:  the symbol is exported out of libpypy-c.so.
-
-   RPY_EXTERN:    the symbol is not exported out of libpypy-c.so, but
-                  otherwise works like 'extern' by being available to
-                  other C sources.
-
-   static:        as usual, this means the symbol is local to this C file.
-
-   Don't use _RPY_HIDDEN directly.  For tests involving building a custom
-   .so, translator/tool/cbuild.py overrides RPY_EXTERN so that it becomes
-   equal to RPY_EXPORTED.
-
-   Any function or global variable declared with no attribute at all is
-   a bug; please report or fix it.
-*/
-#ifdef __GNUC__
-#  define RPY_EXPORTED extern __attribute__((visibility("default")))
-#  define _RPY_HIDDEN  __attribute__((visibility("hidden")))
-#else
-#  define RPY_EXPORTED extern __declspec(dllexport)
-#  define _RPY_HIDDEN  /* nothing */
-#endif
-#ifndef RPY_EXTERN
-#  define RPY_EXTERN   extern _RPY_HIDDEN
-#endif
-
-
-#endif /* __PYPY_PRECOMMONDEFS_H */
-
-/***** End of precommondefs.h *****/
-""")
-
-# back up to pip package top
-for i in range(countdown-1):
-    os.chdir(os.path.pardir)
-
-# add cppyy module to cmake
-os.chdir('src/backend')
-inp = 'CMakeLists.txt'
-print('adding cppyy to cmake')
-outp = inp+'.new'
-new_cml = open(outp, 'w')
-for line in open(inp).readlines():
-    if 'add_subdirectory' in line and 'net' in line:
-        line += 'add_subdirectory (cppyy)\n'
-    new_cml.write(line)
-new_cml.close()
-os.rename(outp, inp)
-
-# done!
diff --git a/pypy/module/_cppyy/bench/Makefile 
b/pypy/module/_cppyy/bench/Makefile
deleted file mode 100644
--- a/pypy/module/_cppyy/bench/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-all: bench02Dict_reflex.so
-
-ROOTSYS := ${ROOTSYS}
-
-ifeq ($(ROOTSYS),)
-  genreflex=genreflex
-  cppflags=
-else
-  genreflex=$(ROOTSYS)/bin/genreflex
-  cppflags=-I$(ROOTSYS)/include -L$(ROOTSYS)/lib
-endif
-
-PLATFORM := $(shell uname -s)
-ifeq ($(PLATFORM),Darwin)
-  cppflags+=-dynamiclib -single_module -arch x86_64
-endif
-
-ifeq ($(shell $(genreflex) --help | grep -- --with-methptrgetter),)
-  genreflexflags=
-  cppflags2=-O3 -fPIC
-else
-  genreflexflags=--with-methptrgetter
-  cppflags2=-Wno-pmf-conversions -O3 -fPIC
-endif
-
-
-bench02Dict_reflex.so: bench02.h bench02.cxx bench02.xml
-       $(genreflex) bench02.h $(genreflexflags) --selection=bench02.xml 
-I$(ROOTSYS)/include
-       g++ -o $@ bench02.cxx bench02_rflx.cpp -I$(ROOTSYS)/include -shared 
-std=c++11 -lHistPainter `root-config --libs` $(cppflags) $(cppflags2)
diff --git a/pypy/module/_cppyy/bench/bench02.cxx 
b/pypy/module/_cppyy/bench/bench02.cxx
deleted file mode 100644
--- a/pypy/module/_cppyy/bench/bench02.cxx
+++ /dev/null
@@ -1,79 +0,0 @@
-#include "bench02.h"
-
-#include "TROOT.h"
-#include "TApplication.h"
-#include "TDirectory.h"
-#include "TInterpreter.h"
-#include "TSystem.h"
-#include "TBenchmark.h"
-#include "TStyle.h"
-#include "TError.h"
-#include "Getline.h"
-#include "TVirtualX.h"
-
-#include "Api.h"
-
-#include <iostream>
-
-TClass *TClass::GetClass(const char*, Bool_t, Bool_t) {
-    static TClass* dummy = new TClass("__dummy__", kTRUE);
-    return dummy;  // is deleted by gROOT at shutdown
-}
-
-class TTestApplication : public TApplication {
-public:
-    TTestApplication(
-        const char* acn, Int_t* argc, char** argv, Bool_t bLoadLibs = kTRUE);
-    virtual ~TTestApplication();
-};
-
-TTestApplication::TTestApplication(
-        const char* acn, int* argc, char** argv, bool do_load) : 
TApplication(acn, argc, argv) {
-    if (do_load) {
-        // follow TRint to minimize differences with CINT
-        ProcessLine("#include <iostream>", kTRUE);
-        ProcessLine("#include <_string>",  kTRUE); // for std::string iostream.
-        ProcessLine("#include <vector>",   kTRUE); // needed because they're 
used within the
-        ProcessLine("#include <pair>",     kTRUE); //  core ROOT dicts and 
CINT won't be able
-                                                   //  to properly unload 
these files
-    }
-
-    // save current interpreter context
-    gInterpreter->SaveContext();
-    gInterpreter->SaveGlobalsContext();
-
-    // prevent crashes on accessing history
-    Gl_histinit((char*)"-");
-
-    // prevent ROOT from exiting python
-    SetReturnFromRun(kTRUE);
-}
-
-TTestApplication::~TTestApplication() {}
-
-static const char* appname = "pypy-cppyy";
-
-Bench02RootApp::Bench02RootApp() {
-    gROOT->SetBatch(kTRUE);
-    if (!gApplication) {
-        int argc = 1;
-        char* argv[1]; argv[0] = (char*)appname;
-        gApplication = new TTestApplication(appname, &argc, argv, kFALSE);
-    }
-}
-
-Bench02RootApp::~Bench02RootApp() {
-    // TODO: ROOT globals cleanup ... (?)
-}
-
-void Bench02RootApp::report() {
-    std::cout << "gROOT is: " << gROOT << std::endl;
-    std::cout << "gApplication is: " << gApplication << std::endl;
-}
-
-void Bench02RootApp::close_file(TFile* f) {
-    std::cout << "closing file " << f->GetName() << " ... " << std::endl;
-    f->Write();
-    f->Close();
-    std::cout << "... file closed" << std::endl;
-}
diff --git a/pypy/module/_cppyy/bench/bench02.h 
b/pypy/module/_cppyy/bench/bench02.h
deleted file mode 100644
--- a/pypy/module/_cppyy/bench/bench02.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#include "TString.h"
-
-#include "TCanvas.h"
-#include "TFile.h"
-#include "TProfile.h"
-#include "TNtuple.h"
-#include "TH1F.h"
-#include "TH2F.h"
-#include "TRandom.h"
-#include "TRandom3.h"
-
-#include "TROOT.h"
-#include "TApplication.h"
-#include "TSystem.h"
-
-#include "TArchiveFile.h"
-#include "TBasket.h"
-#include "TBenchmark.h"
-#include "TBox.h"
-#include "TBranchRef.h"
-#include "TBrowser.h"
-#include "TClassGenerator.h"
-#include "TClassRef.h"
-#include "TClassStreamer.h"
-#include "TContextMenu.h"
-#include "TEntryList.h"
-#include "TEventList.h"
-#include "TF1.h"
-#include "TFileCacheRead.h"
-#include "TFileCacheWrite.h"
-#include "TFileMergeInfo.h"
-#include "TFitResult.h"
-#include "TFolder.h"
-//#include "TFormulaPrimitive.h"
-#include "TFunction.h"
-#include "TFrame.h"
-#include "TGlobal.h"
-#include "THashList.h"
-#include "TInetAddress.h"
-#include "TInterpreter.h"
-#include "TKey.h"
-#include "TLegend.h"
-#include "TMethodCall.h"
-#include "TPluginManager.h"
-#include "TProcessUUID.h"
-#include "TSchemaRuleSet.h"
-#include "TStyle.h"
-#include "TSysEvtHandler.h"
-#include "TTimer.h"
-#include "TView.h"
-//#include "TVirtualCollectionProxy.h"
-#include "TVirtualFFT.h"
-#include "TVirtualHistPainter.h"
-#include "TVirtualIndex.h"
-#include "TVirtualIsAProxy.h"
-#include "TVirtualPadPainter.h"
-#include "TVirtualRefProxy.h"
-#include "TVirtualStreamerInfo.h"
-#include "TVirtualViewer3D.h"
-
-#include <typeinfo>
-#include <ostream>
-
-
-class Bench02RootApp {
-public:
-   Bench02RootApp();
-   ~Bench02RootApp();
-
-   void report();
-   void close_file(TFile* f);
-};
diff --git a/pypy/module/_cppyy/bench/bench02.xml 
b/pypy/module/_cppyy/bench/bench02.xml
deleted file mode 100644
--- a/pypy/module/_cppyy/bench/bench02.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<lcgdict>
-
-  <selection>
-
-     <!-- ROOT classes -->
-     <class pattern="T[A-Z]*" />
-     <class pattern="ROOT::T[A-Z]*" />
-     <class pattern="ROOT::Fit::*" />
-
-     <!-- ROOT globals -->
-     <variable name="gROOT" />
-     <variable name="gSystem" />
-     <variable name="gRandom" />
-
-     <!-- STL classes actually used -->
-     <class name="std::string" />
-     <class name="std::ostream" />
-     <class name="std::type_info" />
-     <class pattern="std::vector<*>" />
-     <class pattern="std::_Vector_base<*>" />
-
-     <!-- helper -->
-     <class name="Bench02RootApp" />
-
-  </selection>
-
-  <exclusion>
-
-     <struct pattern="TString::*" />
-     <class name="TString" >
-         <field name="fRep" transient="true"/>
-     </class>
-
-     <class name="TUUID::uuid_time_t" />
-
-     <class name="TClass::TNameMapNode" />
-     <class name="TFileOpenHandle" />
-
-  </exclusion>
-
-</lcgdict>
diff --git a/pypy/module/_cppyy/bench/hsimple.C 
b/pypy/module/_cppyy/bench/hsimple.C
deleted file mode 100644
--- a/pypy/module/_cppyy/bench/hsimple.C
+++ /dev/null
@@ -1,109 +0,0 @@
-#include <TFile.h>
-#include <TNtuple.h>
-#include <TH2.h>
-#include <TProfile.h>
-#include <TCanvas.h>
-#include <TFrame.h>
-#include <TROOT.h>
-#include <TSystem.h>
-#include <TRandom3.h>
-#include <TBenchmark.h>
-#include <TInterpreter.h>
-
-TFile *hsimple(Int_t get=0)
-{
-//  This program creates :
-//    - a one dimensional histogram
-//    - a two dimensional histogram
-//    - a profile histogram
-//    - a memory-resident ntuple
-//
-//  These objects are filled with some random numbers and saved on a file.
-//  If get=1 the macro returns a pointer to the TFile of "hsimple.root"
-//          if this file exists, otherwise it is created.
-//  The file "hsimple.root" is created in $ROOTSYS/tutorials if the caller has
-//  write access to this directory, otherwise the file is created in $PWD
-
-   TString filename = "hsimple.root";
-   TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
-   dir.ReplaceAll("hsimple.C","");
-   dir.ReplaceAll("/./","/");
-   TFile *hfile = 0;
-   if (get) {
-      // if the argument get =1 return the file "hsimple.root"
-      // if the file does not exist, it is created
-      TString fullPath = dir+"hsimple.root";
-      if (!gSystem->AccessPathName(fullPath,kFileExists)) {
-        hfile = TFile::Open(fullPath); //in $ROOTSYS/tutorials
-         if (hfile) return hfile;
-      }
-      //otherwise try $PWD/hsimple.root
-      if (!gSystem->AccessPathName("hsimple.root",kFileExists)) {
-         hfile = TFile::Open("hsimple.root"); //in current dir
-         if (hfile) return hfile;
-      }
-   }
-   //no hsimple.root file found. Must generate it !
-   //generate hsimple.root in $ROOTSYS/tutorials if we have write access
-   if (!gSystem->AccessPathName(dir,kWritePermission)) {
-      filename = dir+"hsimple.root";
-   } else if (!gSystem->AccessPathName(".",kWritePermission)) {
-      //otherwise generate hsimple.root in the current directory
-   } else {
-      printf("you must run the script in a directory with write access\n");
-      return 0;
-   }
-   hfile = (TFile*)gROOT->FindObject(filename); if (hfile) hfile->Close();
-   hfile = new TFile(filename,"RECREATE","Demo ROOT file with histograms");
-
-   // Create some histograms, a profile histogram and an ntuple
-   TH1F *hpx = new TH1F("hpx","This is the px distribution",100,-4,4);
-   hpx->SetFillColor(48);
-   TH2F *hpxpy = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
-   TProfile *hprof = new TProfile("hprof","Profile of pz versus 
px",100,-4,4,0,20);
-   TNtuple *ntuple = new TNtuple("ntuple","Demo ntuple","px:py:pz:random:i");
-
-   gBenchmark->Start("hsimple");
-  
-   // Create a new canvas.
-   TCanvas *c1 = new TCanvas("c1","Dynamic Filling Example",200,10,700,500);
-   c1->SetFillColor(42);
-   c1->GetFrame()->SetFillColor(21);
-   c1->GetFrame()->SetBorderSize(6);
-   c1->GetFrame()->SetBorderMode(-1);
-
-
-   // Fill histograms randomly
-   TRandom3 random;
-   Float_t px, py, pz;
-   const Int_t kUPDATE = 1000;
-   for (Int_t i = 0; i < 50000; i++) {
-   //      random.Rannor(px,py);
-      px = random.Gaus(0, 1);
-      py = random.Gaus(0, 1);
-      pz = px*px + py*py;
-      Float_t rnd = random.Rndm(1);
-      hpx->Fill(px);
-      hpxpy->Fill(px,py);
-      hprof->Fill(px,pz);
-      ntuple->Fill(px,py,pz,rnd,i);
-      if (i && (i%kUPDATE) == 0) {
-         if (i == kUPDATE) hpx->Draw();
-         c1->Modified();
-         c1->Update();
-         if (gSystem->ProcessEvents())
-            break;
-      }
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to