Author: Carl Friedrich Bolz <cfb...@gmx.de> Branch: optinfo-into-bridges Changeset: r88371:b0c428c5ac48 Date: 2016-11-13 16:57 +0100 http://bitbucket.org/pypy/pypy/changeset/b0c428c5ac48/
Log: merge default diff too long, truncating to 2000 out of 15945 lines diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -33,3 +33,4 @@ 050d84dd78997f021acf0e133934275d63547cc0 release-pypy2.7-v5.4.1 050d84dd78997f021acf0e133934275d63547cc0 release-pypy2.7-v5.4.1 0e2d9a73f5a1818d0245d75daccdbe21b2d5c3ef release-pypy2.7-v5.4.1 +aff251e543859ce4508159dd9f1a82a2f553de00 release-pypy2.7-v5.6.0 diff --git a/LICENSE b/LICENSE --- a/LICENSE +++ b/LICENSE @@ -44,15 +44,15 @@ Matti Picus Alex Gaynor Philip Jenvey + Ronan Lamy Brian Kearns - Ronan Lamy + Richard Plangger Michael Hudson Manuel Jacob David Schneider Holger Krekel Christian Tismer Hakan Ardo - Richard Plangger Benjamin Peterson Anders Chrigstrom Eric van Riet Paap @@ -68,8 +68,8 @@ Niklaus Haldimann Camillo Bruni Laura Creighton + Romain Guillebert Toon Verwaest - Romain Guillebert Leonardo Santagada Seo Sanghyeon Ronny Pfannschmidt @@ -89,7 +89,9 @@ Ludovic Aubry Jacob Hallen Jason Creighton + Mark Young Alex Martelli + Spenser Bauman Michal Bendowski stian Jan de Mooij @@ -100,20 +102,21 @@ Stefan Schwarzer Valentino Volonghi Tomek Meka + Stefano Rivera Patrick Maupin + Devin Jeanpierre Bob Ippolito Bruno Gola David Malcolm Jean-Paul Calderone - Mark Young Timo Paulssen + Edd Barrett Squeaky - Devin Jeanpierre Marius Gedminas Alexandre Fayolle Simon Burton - Stefano Rivera Martin Matusiak + Nicolas Truessel Konstantin Lopuhin Wenzhu Man John Witulski @@ -123,14 +126,12 @@ Dario Bertini Mark Pearse Simon Cross - Edd Barrett + Jeremy Thurgood Andreas Stührk Tobias Pape Jean-Philippe St. Pierre Guido van Rossum Pavel Vinogradov - Spenser Bauman - Jeremy Thurgood Paweł Piotr Przeradowski Paul deGrandis Ilya Osadchiy @@ -141,7 +142,6 @@ tav Taavi Burns Georg Brandl - Nicolas Truessel Bert Freudenberg Stian Andreassen Wanja Saatkamp @@ -156,19 +156,20 @@ Preston Timmons David Ripton Jeff Terrace + Tim Felgentreff Dusty Phillips Lukas Renggli Guenter Jantzen William Leslie Ned Batchelder - Tim Felgentreff Anton Gulenko Amit Regmi Ben Young - Sergey Matyunin + Jasper Schulz Nicolas Chauvat Andrew Durdin Andrew Chambers + Sergey Matyunin Michael Schneider Nicholas Riley Jason Chu @@ -184,16 +185,16 @@ Jared Grubb Karl Bartel Wouter van Heyst - Sebastian Pawluś Brian Dorsey Victor Stinner Andrews Medina + Sebastian Pawluś Stuart Williams - Jasper Schulz - Christian Hudon + Daniel Patrick + Aaron Iles Toby Watson Antoine Pitrou - Aaron Iles + Christian Hudon Michael Cheng Justas Sadzevicius Gasper Zejn @@ -201,8 +202,8 @@ Stanislaw Halik Mikael Schönenberg Berkin Ilbeyi + Faye Zhao Elmo Mäntynen - Faye Zhao Jonathan David Riehl Anders Qvist Corbin Simpson @@ -211,11 +212,12 @@ Alex Perry Vaibhav Sood Alan McIntyre + Reuben Cummings Alexander Sedov p_ziesch...@yahoo.de Attila Gobi - Jasper.Schulz Christopher Pope + Aaron Gallagher Florin Papa Christian Tismer Marc Abramowitz @@ -232,7 +234,6 @@ Gabriel Lukas Vacek Kunal Grover - Aaron Gallagher Andrew Dalke Sylvain Thenault Jakub Stasiak @@ -255,6 +256,7 @@ Philipp Rustemeuer Henrik Vendelbo Richard Lancaster + Yasir Suhail Dan Buch Miguel de Val Borro Artur Lisiecki @@ -267,6 +269,7 @@ Catalin Gabriel Manciu Tomo Cocoa Kim Jin Su + rafalgalczyn...@gmail.com Toni Mattis Amber Brown Lucas Stadler @@ -294,9 +297,7 @@ Michael Hudson-Doyle Anders Sigfridsson Nikolay Zinov - Yasir Suhail Jason Michalski - rafalgalczyn...@gmail.com Floris Bruynooghe Laurens Van Houtven Akira Li @@ -310,9 +311,10 @@ James Lan Volodymyr Vladymyrov shoma hosaka - Daniel Neuhäuser Ben Mather Niclas Olofsson + Matthew Miller + Rodrigo Araújo halgari Boglarka Vezer Chris Pressey @@ -322,8 +324,9 @@ Dinu Gherman Chris Lambacher coolbutusel...@gmail.com + Daniil Yarancev Jim Baker - Rodrigo Araújo + Dan Crosta Nikolaos-Digenis Karagiannis James Robert Armin Ronacher @@ -337,32 +340,31 @@ Tomer Chachamu Christopher Groskopf Asmo Soinio - Stefan Marr jiaaro Mads Kiilerich - opassembler.py Antony Lee Jason Madden + Daniel Neuh�user + reub...@gmail.com Yaroslav Fedevych Jim Hunziker Markus Unterwaditzer Even Wiik Thomassen jbs squeaky - Zearin soareschen Jonas Pfannschmidt Kurt Griffiths Mike Bayer - Matthew Miller + Stefan Marr Flavio Percoco Kristoffer Kleine - yasirs Michael Chermside Anna Ravencroft pizi + remarkablerocket Andrey Churin - Dan Crosta + Zearin Eli Stevens Tobias Diaz Julien Phalip diff --git a/lib-python/2.7/ctypes/test/test_bitfields.py b/lib-python/2.7/ctypes/test/test_bitfields.py --- a/lib-python/2.7/ctypes/test/test_bitfields.py +++ b/lib-python/2.7/ctypes/test/test_bitfields.py @@ -2,6 +2,7 @@ from ctypes.test import need_symbol, xfail import unittest import os +import sys import ctypes import _ctypes_test @@ -279,7 +280,6 @@ x.c = 2 self.assertEqual(b.tostring(), b'\xef\xcd\xab\x21') - @xfail @need_symbol('c_uint32') def test_uint32_swap_big_endian(self): # Issue #23319 @@ -295,5 +295,11 @@ x.c = 2 self.assertEqual(b.tostring(), b'\xab\xcd\xef\x12') + # see issue #1213, on big endian it fails for the little endian case + if sys.byteorder == 'little': + test_uint32_swap_big_endian = xfail(test_uint32_swap_big_endian) + elif sys.byteorder == 'big': + test_uint32_swap_little_endian = xfail(test_uint32_swap_little_endian) + if __name__ == "__main__": unittest.main() diff --git a/lib-python/2.7/test/test_ssl.py b/lib-python/2.7/test/test_ssl.py --- a/lib-python/2.7/test/test_ssl.py +++ b/lib-python/2.7/test/test_ssl.py @@ -26,6 +26,8 @@ PROTOCOLS = sorted(ssl._PROTOCOL_NAMES) HOST = support.HOST +IS_LIBRESSL = ssl.OPENSSL_VERSION.startswith('LibreSSL') +IS_OPENSSL_1_1 = not IS_LIBRESSL and ssl.OPENSSL_VERSION_INFO >= (1, 1, 0) def data_file(*name): return os.path.join(os.path.dirname(__file__), *name) @@ -742,15 +744,15 @@ def test_options(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # OP_ALL | OP_NO_SSLv2 | OP_NO_SSLv3 is the default value - self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3, - ctx.options) + default = (ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3) + if not IS_LIBRESSL and ssl.OPENSSL_VERSION_INFO >= (1, 1, 0): + default |= ssl.OP_NO_COMPRESSION + self.assertEqual(default, ctx.options) ctx.options |= ssl.OP_NO_TLSv1 - self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3 | ssl.OP_NO_TLSv1, - ctx.options) + self.assertEqual(default | ssl.OP_NO_TLSv1, ctx.options) if can_clear_options(): - ctx.options = (ctx.options & ~ssl.OP_NO_SSLv2) | ssl.OP_NO_TLSv1 - self.assertEqual(ssl.OP_ALL | ssl.OP_NO_TLSv1 | ssl.OP_NO_SSLv3, - ctx.options) + ctx.options = (ctx.options & ~ssl.OP_NO_TLSv1) + self.assertEqual(default, ctx.options) ctx.options = 0 self.assertEqual(0, ctx.options) else: @@ -2918,18 +2920,27 @@ client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) client_context.load_cert_chain(CERTFILE) client_context.set_alpn_protocols(client_protocols) - stats = server_params_test(client_context, server_context, - chatty=True, connectionchatty=True) - - msg = "failed trying %s (s) and %s (c).\n" \ - "was expecting %s, but got %%s from the %%s" \ - % (str(server_protocols), str(client_protocols), - str(expected)) - client_result = stats['client_alpn_protocol'] - self.assertEqual(client_result, expected, msg % (client_result, "client")) - server_result = stats['server_alpn_protocols'][-1] \ - if len(stats['server_alpn_protocols']) else 'nothing' - self.assertEqual(server_result, expected, msg % (server_result, "server")) + try: + stats = server_params_test(client_context, server_context, + chatty=True, connectionchatty=True) + except ssl.SSLError as e: + stats = e + + if expected is None and IS_OPENSSL_1_1: + # OpenSSL 1.1.0 raises handshake error + self.assertIsInstance(stats, ssl.SSLError) + else: + msg = "failed trying %s (s) and %s (c).\n" \ + "was expecting %s, but got %%s from the %%s" \ + % (str(server_protocols), str(client_protocols), + str(expected)) + client_result = stats['client_alpn_protocol'] + self.assertEqual(client_result, expected, + msg % (client_result, "client")) + server_result = stats['server_alpn_protocols'][-1] \ + if len(stats['server_alpn_protocols']) else 'nothing' + self.assertEqual(server_result, expected, + msg % (server_result, "server")) def test_selected_npn_protocol(self): # selected_npn_protocol() is None unless NPN is used diff --git a/lib_pypy/_collections.py b/lib_pypy/_collections.py --- a/lib_pypy/_collections.py +++ b/lib_pypy/_collections.py @@ -29,7 +29,7 @@ class deque(object): def __new__(cls, iterable=(), *args, **kw): - self = super(deque, cls).__new__(cls, *args, **kw) + self = super(deque, cls).__new__(cls) self.clear() return 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 @@ -229,7 +229,7 @@ __metaclass__ = StructOrUnionMeta def __new__(cls, *args, **kwds): - self = super(_CData, cls).__new__(cls, *args, **kwds) + self = super(_CData, cls).__new__(cls) if '_abstract_' in cls.__dict__: raise TypeError("abstract class") if hasattr(cls, '_ffistruct_'): 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.8.4 +Version: 1.9.0 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, CDefError, FFIError from .ffiplatform import VerificationError, VerificationMissing -__version__ = "1.8.4" -__version_info__ = (1, 8, 4) +__version__ = "1.9.0" +__version_info__ = (1, 9, 0) # 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 @@ -141,9 +141,9 @@ #define _cffi_to_c_char \ ((int(*)(PyObject *))_cffi_exports[9]) #define _cffi_from_c_pointer \ - ((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[10]) + ((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[10]) #define _cffi_to_c_pointer \ - ((char *(*)(PyObject *, CTypeDescrObject *))_cffi_exports[11]) + ((char *(*)(PyObject *, struct _cffi_ctypedescr *))_cffi_exports[11]) #define _cffi_get_struct_layout \ not used any more #define _cffi_restore_errno \ @@ -153,11 +153,11 @@ #define _cffi_from_c_char \ ((PyObject *(*)(char))_cffi_exports[15]) #define _cffi_from_c_deref \ - ((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[16]) + ((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[16]) #define _cffi_to_c \ - ((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[17]) + ((int(*)(char *, struct _cffi_ctypedescr *, PyObject *))_cffi_exports[17]) #define _cffi_from_c_struct \ - ((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[18]) + ((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[18]) #define _cffi_to_c_wchar_t \ ((wchar_t(*)(PyObject *))_cffi_exports[19]) #define _cffi_from_c_wchar_t \ @@ -167,21 +167,22 @@ #define _cffi_to_c__Bool \ ((_Bool(*)(PyObject *))_cffi_exports[22]) #define _cffi_prepare_pointer_call_argument \ - ((Py_ssize_t(*)(CTypeDescrObject *, PyObject *, char **))_cffi_exports[23]) + ((Py_ssize_t(*)(struct _cffi_ctypedescr *, \ + PyObject *, char **))_cffi_exports[23]) #define _cffi_convert_array_from_object \ - ((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[24]) + ((int(*)(char *, struct _cffi_ctypedescr *, PyObject *))_cffi_exports[24]) #define _CFFI_CPIDX 25 #define _cffi_call_python \ ((void(*)(struct _cffi_externpy_s *, char *))_cffi_exports[_CFFI_CPIDX]) #define _CFFI_NUM_EXPORTS 26 -typedef struct _ctypedescr CTypeDescrObject; +struct _cffi_ctypedescr; static void *_cffi_exports[_CFFI_NUM_EXPORTS]; #define _cffi_type(index) ( \ assert((((uintptr_t)_cffi_types[index]) & 1) == 0), \ - (CTypeDescrObject *)_cffi_types[index]) + (struct _cffi_ctypedescr *)_cffi_types[index]) static PyObject *_cffi_init(const char *module_name, Py_ssize_t version, const struct _cffi_type_context_s *ctx) 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 @@ -233,7 +233,7 @@ f = PySys_GetObject((char *)"stderr"); if (f != NULL && f != Py_None) { PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME - "\ncompiled with cffi version: 1.8.4" + "\ncompiled with cffi version: 1.9.0" "\n_cffi_backend module: ", f); modules = PyImport_GetModuleDict(); mod = PyDict_GetItemString(modules, "_cffi_backend"); @@ -366,7 +366,7 @@ const char *code; } _cffi_pypy_init = { _CFFI_MODULE_NAME, - _CFFI_PYTHON_STARTUP_FUNC, + (void(*)(const void *[]))_CFFI_PYTHON_STARTUP_FUNC, _CFFI_PYTHON_STARTUP_CODE, }; 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 @@ -334,6 +334,8 @@ realtype, quals = self._get_type_and_quals( decl.type, name=decl.name, partial_length_ok=True) self._declare('typedef ' + decl.name, realtype, quals=quals) + elif decl.__class__.__name__ == 'Pragma': + pass # skip pragma, only in pycparser 2.15 else: raise api.CDefError("unrecognized construct", decl) except api.FFIError as e: diff --git a/lib_pypy/cffi/model.py b/lib_pypy/cffi/model.py --- a/lib_pypy/cffi/model.py +++ b/lib_pypy/cffi/model.py @@ -519,10 +519,18 @@ smallest_value = min(self.enumvalues) largest_value = max(self.enumvalues) else: - raise api.CDefError("%r has no values explicitly defined: " - "refusing to guess which integer type it is " - "meant to be (unsigned/signed, int/long)" - % self._get_c_name()) + import warnings + try: + # XXX! The goal is to ensure that the warnings.warn() + # will not suppress the warning. We want to get it + # several times if we reach this point several times. + __warningregistry__.clear() + except NameError: + pass + warnings.warn("%r has no values explicitly defined; " + "guessing that it is equivalent to 'unsigned int'" + % self._get_c_name()) + smallest_value = largest_value = 0 if smallest_value < 0: # needs a signed type sign = 1 candidate1 = PrimitiveType("int") diff --git a/lib_pypy/cffi/setuptools_ext.py b/lib_pypy/cffi/setuptools_ext.py --- a/lib_pypy/cffi/setuptools_ext.py +++ b/lib_pypy/cffi/setuptools_ext.py @@ -1,4 +1,5 @@ import os +import sys try: basestring @@ -74,8 +75,13 @@ Add py_limited_api to kwds if setuptools >= 26 is in use. Do not alter the setting if it already exists. Setuptools takes care of ignoring the flag on Python 2 and PyPy. + + CPython itself should ignore the flag in a debugging version + (by not listing .abi3.so in the extensions it supports), but + it doesn't so far, creating troubles. That's why we check + for "not sys.flags.debug". (http://bugs.python.org/issue28401) """ - if 'py_limited_api' not in kwds: + if 'py_limited_api' not in kwds and not sys.flags.debug: import setuptools try: setuptools_major_version = int(setuptools.__version__.partition('.')[0]) diff --git a/pypy/doc/contributor.rst b/pypy/doc/contributor.rst --- a/pypy/doc/contributor.rst +++ b/pypy/doc/contributor.rst @@ -9,8 +9,8 @@ Philip Jenvey Ronan Lamy Brian Kearns + Richard Plangger Michael Hudson - Richard Plangger Manuel Jacob David Schneider Holger Krekel @@ -54,10 +54,10 @@ Jason Creighton Mark Young Alex Martelli + Spenser Bauman Michal Bendowski stian Jan de Mooij - Spenser Bauman Tyler Wade Vincent Legoll Michael Foord @@ -65,13 +65,13 @@ Stefan Schwarzer Valentino Volonghi Tomek Meka + Stefano Rivera Patrick Maupin Devin Jeanpierre Bob Ippolito Bruno Gola David Malcolm Jean-Paul Calderone - Stefano Rivera Timo Paulssen Edd Barrett Squeaky @@ -89,12 +89,12 @@ Dario Bertini Mark Pearse Simon Cross + Jeremy Thurgood Andreas Stührk Tobias Pape Jean-Philippe St. Pierre Guido van Rossum Pavel Vinogradov - Jeremy Thurgood Paweł Piotr Przeradowski Paul deGrandis Ilya Osadchiy @@ -128,10 +128,11 @@ Anton Gulenko Amit Regmi Ben Young - Sergey Matyunin + Jasper Schulz Nicolas Chauvat Andrew Durdin Andrew Chambers + Sergey Matyunin Michael Schneider Nicholas Riley Jason Chu @@ -147,17 +148,16 @@ Jared Grubb Karl Bartel Wouter van Heyst - Sebastian Pawluś Brian Dorsey Victor Stinner Andrews Medina + Sebastian Pawluś Stuart Williams Daniel Patrick - Jasper Schulz - Christian Hudon + Aaron Iles Toby Watson Antoine Pitrou - Aaron Iles + Christian Hudon Michael Cheng Justas Sadzevicius Gasper Zejn @@ -165,8 +165,8 @@ Stanislaw Halik Mikael Schönenberg Berkin Ilbeyi + Faye Zhao Elmo Mäntynen - Faye Zhao Jonathan David Riehl Anders Qvist Corbin Simpson @@ -175,11 +175,12 @@ Alex Perry Vaibhav Sood Alan McIntyre + Reuben Cummings Alexander Sedov p_ziesch...@yahoo.de Attila Gobi - Jasper.Schulz Christopher Pope + Aaron Gallagher Florin Papa Christian Tismer Marc Abramowitz @@ -196,7 +197,6 @@ Gabriel Lukas Vacek Kunal Grover - Aaron Gallagher Andrew Dalke Sylvain Thenault Jakub Stasiak @@ -219,6 +219,7 @@ Philipp Rustemeuer Henrik Vendelbo Richard Lancaster + Yasir Suhail Dan Buch Miguel de Val Borro Artur Lisiecki @@ -231,6 +232,7 @@ Catalin Gabriel Manciu Tomo Cocoa Kim Jin Su + rafalgalczyn...@gmail.com Toni Mattis Amber Brown Lucas Stadler @@ -258,9 +260,7 @@ Michael Hudson-Doyle Anders Sigfridsson Nikolay Zinov - Yasir Suhail Jason Michalski - rafalgalczyn...@gmail.com Floris Bruynooghe Laurens Van Houtven Akira Li @@ -274,10 +274,10 @@ James Lan Volodymyr Vladymyrov shoma hosaka - Daniel Neuhäuser Ben Mather Niclas Olofsson - "Aaron Gallagher + Matthew Miller + Rodrigo Araújo halgari Boglarka Vezer Chris Pressey @@ -287,8 +287,9 @@ Dinu Gherman Chris Lambacher coolbutusel...@gmail.com + Daniil Yarancev Jim Baker - Rodrigo Araújo + Dan Crosta Nikolaos-Digenis Karagiannis James Robert Armin Ronacher @@ -302,13 +303,11 @@ Tomer Chachamu Christopher Groskopf Asmo Soinio - Stefan Marr jiaaro Mads Kiilerich - opassembler.py - JohnDoe Antony Lee Jason Madden + Daniel Neuh�user reub...@gmail.com Yaroslav Fedevych Jim Hunziker @@ -316,25 +315,24 @@ Even Wiik Thomassen jbs squeaky - Zearin soareschen Jonas Pfannschmidt Kurt Griffiths Mike Bayer - Matthew Miller + Stefan Marr Flavio Percoco Kristoffer Kleine - yasirs Michael Chermside Anna Ravencroft pizi remarkablerocket Andrey Churin - Dan Crosta + Zearin Eli Stevens Tobias Diaz Julien Phalip Roman Podoliaka Dan Loewenherz werat - hgattic + + diff --git a/pypy/doc/faq.rst b/pypy/doc/faq.rst --- a/pypy/doc/faq.rst +++ b/pypy/doc/faq.rst @@ -397,3 +397,28 @@ in auto-generated C code, and at least some knowledge about the various components involved, from PyPy's own RPython source code to the GC and possibly the JIT. + + +Why doesn't PyPy move to GitHub, Gitlab, ...? +---------------------------------------------- + +We've been quite happy with bitbucket.org. Moving version control systems and +hosting is a lot of hard work: On the one hand, PyPy's mercurial history is +long and gnarly. On the other hand, all our infrastructure (buildbots, +benchmarking, etc) would have to be adapted. So unless somebody steps up and +volunteers to do all that work, it will likely not happen. + + +What is needed for Windows 64 support of PyPy? +----------------------------------------------- + +First, please note that the Windows 32 PyPy binary works just fine on Windows +64. The only problem is that it only supports up to 4GB of heap per process. + +As to real Windows 64 support: Currently we don't have an active PyPy developer +whose main development platform is Windows. So if you are interested in getting +Windows 64 support, we encourage you to volunteer `to make it happen`_! Another +option would be to pay some PyPy developers to implement Windows 64 support, +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 diff --git a/pypy/doc/how-to-release.rst b/pypy/doc/how-to-release.rst --- a/pypy/doc/how-to-release.rst +++ b/pypy/doc/how-to-release.rst @@ -1,4 +1,4 @@ -The PyPy Release Process +PyPy's Release Process ======================== Release Policy @@ -39,41 +39,60 @@ Some of the next updates may be done before or after branching; make sure things are ported back to the trunk and to the branch as necessary. -* update pypy/doc/contributor.rst (and possibly LICENSE) - pypy/doc/tool/makecontributor.py generates the list of contributors -* rename pypy/doc/whatsnew_head.rst to whatsnew_VERSION.rst - create a fresh whatsnew_head.rst after the release - and add the new file to pypy/doc/index-of-whatsnew.rst -* go to pypy/tool/release and run - ``force-builds.py <release branch>`` - The following JIT binaries should be built, however, we need more buildbots - windows, linux-32, linux-64, osx64, armhf-raring, armhf-raspberrian, armel, - freebsd64 -* wait for builds to complete, make sure there are no failures -* download the builds, repackage binaries. Tag the release version - and download and repackage source from bitbucket. You may find it - convenient to use the ``repackage.sh`` script in pypy/tool/release to do this. +* Update and write documentation - Otherwise repackage and upload source "-src.tar.bz2" to bitbucket - and to cobra, as some packagers prefer a clearly labeled source package - ( download e.g. https://bitbucket.org/pypy/pypy/get/release-2.5.x.tar.bz2, - unpack, rename the top-level directory to "pypy-2.5.0-src", repack, and upload) + * update pypy/doc/contributor.rst (and possibly LICENSE) + pypy/doc/tool/makecontributor.py generates the list of contributors -* Upload binaries to https://bitbucket.org/pypy/pypy/downloads + * rename pypy/doc/whatsnew_head.rst to whatsnew_VERSION.rst + create a fresh whatsnew_head.rst after the release + and add the new file to pypy/doc/index-of-whatsnew.rst -* write release announcement pypy/doc/release-x.y(.z).txt + * write release announcement pypy/doc/release-VERSION.rst + The release announcement should contain a direct link to the download page - The release announcement should contain a direct link to the download page + * Add the new files to pypy/doc/index-of-{whatsnew,release-notes}.rst -* Add the new files to pypy/doc/index-of-{whatsnew,release-notes}.rst +* Build and upload the release tar-balls -* update pypy.org (under extradoc/pypy.org), rebuild and commit + * go to pypy/tool/release and run + ``force-builds.py <release branch>`` + The following JIT binaries should be built, however, we need more buildbots + windows, linux-32, linux-64, osx64, armhf-raring, armhf-raspberrian, armel, + freebsd64 -* post announcement on morepypy.blogspot.com -* send announcements to twitter.com, pypy-dev, python-list, - python-announce, python-dev ... + * wait for builds to complete, make sure there are no failures -* add a tag on the pypy/jitviewer repo that corresponds to pypy release -* add a tag on the codespeed web site that corresponds to pypy release -* revise versioning at https://readthedocs.org/projects/pypy + * send out a mailing list message asking for people to test before uploading + to prevent having to upload more than once + + * add a tag on the pypy/jitviewer repo that corresponds to pypy release, so + that the source tarball can be produced in the next steps + + * download the builds, repackage binaries. Tag the release version + and download and repackage source from bitbucket. You may find it + convenient to use the ``repackage.sh`` script in pypy/tool/release to do this. + + Otherwise repackage and upload source "-src.tar.bz2" to bitbucket + and to cobra, as some packagers prefer a clearly labeled source package + ( download e.g. https://bitbucket.org/pypy/pypy/get/release-2.5.x.tar.bz2, + unpack, rename the top-level directory to "pypy-2.5.0-src", repack, and upload) + + * Upload binaries to https://bitbucket.org/pypy/pypy/downloads + +* Send out a mailing list message asking for last-minute comments and testing + +* RELEASE ! + + * update pypy.org (under extradoc/pypy.org), rebuild and commit, using the + hashes produced from the ``repackage.sh`` script or by hand + + * post announcement on morepypy.blogspot.com + * send announcements to twitter.com, pypy-dev, python-list, + python-announce, python-dev ... + +* If all is OK, document the released version + + * add a tag on the codespeed web site that corresponds to pypy release + * revise versioning at https://readthedocs.org/projects/pypy diff --git a/pypy/doc/index-of-release-notes.rst b/pypy/doc/index-of-release-notes.rst --- a/pypy/doc/index-of-release-notes.rst +++ b/pypy/doc/index-of-release-notes.rst @@ -6,6 +6,7 @@ .. toctree:: + release-pypy2.7-v5.6.0.rst release-pypy2.7-v5.4.1.rst release-pypy2.7-v5.4.0.rst release-pypy2.7-v5.3.1.rst diff --git a/pypy/doc/index-of-whatsnew.rst b/pypy/doc/index-of-whatsnew.rst --- a/pypy/doc/index-of-whatsnew.rst +++ b/pypy/doc/index-of-whatsnew.rst @@ -7,6 +7,7 @@ .. toctree:: whatsnew-head.rst + whatsnew-pypy2-5.6.0.rst whatsnew-pypy2-5.4.0.rst whatsnew-pypy2-5.3.1.rst whatsnew-pypy2-5.3.0.rst diff --git a/pypy/doc/install.rst b/pypy/doc/install.rst --- a/pypy/doc/install.rst +++ b/pypy/doc/install.rst @@ -1,8 +1,17 @@ Downloading and Installing PyPy =============================== +Using a packaged PyPy +~~~~~~~~~~~~~~~~~~~~~ + +Some Linux distributions provide a pypy package. Note that in order to +install additional modules that require compilation, you may need to install +additional packages such as pypy-dev. This will manifest as an error about +"missing Python.h". Distributions do not as of yet supply many pypy-ready +packages, if you require additional modules we recommend creating a virtualenv +and using pip. + .. _prebuilt-pypy: - Download a pre-built PyPy ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -38,6 +47,9 @@ and not move the binary there, else PyPy would not be able to find its library. +Installing more modules +~~~~~~~~~~~~~~~~~~~~~~~ + If you want to install 3rd party libraries, the most convenient way is to install pip_ using ensurepip_ (unless you want to install virtualenv as explained below; then you can directly use pip inside virtualenvs): diff --git a/pypy/doc/release-pypy2.7-v5.6.0.rst b/pypy/doc/release-pypy2.7-v5.6.0.rst new file mode 100644 --- /dev/null +++ b/pypy/doc/release-pypy2.7-v5.6.0.rst @@ -0,0 +1,155 @@ +============ +PyPy2.7 v5.6 +============ + +We have released PyPy2.7 v5.6, about two months after PyPy2.7 v5.4. +This new PyPy2.7 release includes the upstream stdlib version 2.7.12. + +We continue to make incremental improvements to our C-API +compatibility layer (cpyext). We pass all but a few of the tests in the +upstream numpy `test suite`_. + +Work proceeds at a good pace on the PyPy3.5 +version due to a grant_ from the Mozilla Foundation, and some of those +changes have been backported to PyPy2.7 where relevant. + +The PowerPC and s390x backend have been enhanced_ with the capability use SIMD instructions + for micronumpy loops. + +We changed ``timeit`` to now report average +- standard deviation, which is +better than the misleading minimum value reported in CPython. + +We now support building PyPy with OpenSSL 1.1 in our built-in _ssl module, as +well as maintaining support for previous versions. + +CFFI_ has been updated to 1.9, improving an already great package for +interfacing with C. + +As always, this release fixed many issues and bugs raised by the +growing community of PyPy users. We strongly recommend updating. + +You can download the PyPy2.7 v5.6 release here: + + http://pypy.org/download.html + +We would like to thank our donors for the continued support of the PyPy +project. + +We would also like to thank our contributors and +encourage new people to join the project. PyPy has many +layers and we need help with all of them: `PyPy`_ and `RPython`_ documentation +improvements, tweaking popular `modules`_ to run on pypy, or general `help`_ +with making RPython's JIT even better. + +.. _`test suite`: https://bitbucket.org/pypy/pypy/wiki/Adventures%20in%20cpyext%20compatibility +.. _CFFI: https://cffi.readthedocs.io/en/latest/whatsnew.html +.. _grant: https://morepypy.blogspot.com/2016/08/pypy-gets-funding-from-mozilla-for.html +.. _`PyPy`: http://doc.pypy.org +.. _`RPython`: https://rpython.readthedocs.org +.. _`modules`: http://doc.pypy.org/en/latest/project-ideas.html#make-more-python-modules-pypy-friendly +.. _`help`: http://doc.pypy.org/en/latest/project-ideas.html +.. _`enhanced`: https://morepypy.blogspot.co.at/2016/11/vectorization-extended-powerpc-and-s390x.html + +What is PyPy? +============= + +PyPy is a very compliant Python interpreter, almost a drop-in replacement for +CPython 2.7. It's fast (`PyPy and CPython 2.7.x`_ performance comparison) +due to its integrated tracing JIT compiler. + +We also welcome developers of other `dynamic languages`_ to see what RPython +can do for them. + +This release supports: + + * **x86** machines on most common operating systems + (Linux 32/64 bits, Mac OS X 64 bits, Windows 32 bits, OpenBSD, FreeBSD) + + * newer **ARM** hardware (ARMv6 or ARMv7, with VFPv3) running Linux, + + * big- and little-endian variants of **PPC64** running Linux, + + * **s390x** running Linux + +.. _`PyPy and CPython 2.7.x`: http://speed.pypy.org +.. _`dynamic languages`: http://rpython.readthedocs.io/en/latest/examples.html + +Other Highlights (since 5.4 released Aug 31, 2016) +========================================================= + +* New features + + * Allow tests run with `-A` to find `libm.so` even if it is a script not a + dynamically loadable file + * Backport fixes to rposix on windows from py3.5 + * Allow user-defined ``__getitem__`` on subclasses of ``str`` and ``unicode`` + * Add ``inode`` to ``scandir()`` on posix systems + * Support more attributes on ``super`` + * Issue #2386: non-latin1 unicode keys were ignored in ``unicode.format(**d)`` + * Restore the ability to translate with CPython + * Update to CFFI 1.9.0 + * Support the new buffer protocol in cpyext and numpypy + * Add ``rposix.sync()`` + * Support full-precision nanosecond times in os.stat() + * Add documentation about the assembler backends to RPYthon + * Search for the stdlibs from the libpypy shared object rather than the pypy-c exe, + changes downstream packaging requirements + * Add ``try_inline``, like ``always_inline`` and ``dont_inline`` to RPython + * Reject ``'a'.strip(buffer(' '))`` like cpython (the argument to strip must + be ``str`` or ``unicode``) + * Allow ``warning.warn(('something', 1), Warning)`` like on CPython + * Refactor ``rclock`` and add some more ``CLOCK_xxx`` constants on + relevant platforms + * Backport the ``faulthandler`` module from py3.5 + * Improve the error message when trying to call a method where the ``self`` + parameter is missing in the definition + * Implement ``rposix.cpu_count`` + * Support translation on FreeBSD running on PowerPC + * Implement ``__rmod__`` on ``str`` and ``unicode`` types + * Issue warnings for stricter handling of ``__new__``, ``__init__`` args + * When using ``struct.unpack('q', ...`` try harder to prefer int to long + * Support OpenSSL version 1.1 (in addition to version 1.0) + +* Bug Fixes + + * Tweak a float comparison with 0 in `backendopt.inline` to avoid rounding errors + * Fix translation of the sandbox + * Fix for an issue where `unicode.decode('utf8', 'custom_replace')` messed up + the last byte of a unicode string sometimes + * fix some calls to functions through window's COM interface + * fix minor leak when the C call to socketpair() fails + * make sure (-1.0 + 0j).__hash__(), (-1.0).__hash__() returns -2 + * Fix for an issue where PyBytesResize was called on a fresh pyobj + * Fix bug in codewriter about passing the ``exitswitch`` variable to a call + * Don't crash in ``merge_if_blocks`` if the values are symbolics + * Issue #2325/2361: __class__ assignment between two classes with the same + slots + * Issue #2409: don't leak the file descriptor when doing ``open('some-dir')`` + * Windows fixes around vmprof + * Don't use ``sprintf()`` from inside a signal handler + * Test and fix bug from the ``guard_not_forced_2`` branch, which didn't + save the floating-point register + * ``_numpypy.add.reduce`` returns a scalar now + +* Performance improvements: + + * Improve method calls on oldstyle classes + * Clean and refactor code for testing cpyext to allow sharing with py3.5 + * Refactor a building the map of reflected ops in ``_numpypy`` + * Improve merging of virtual states in the JIT in order to avoid jumping to the + preamble + * In JIT residual calls, if the called function starts with a fast-path like + ``if x.foo != 0: return x.foo``, then inline the check before doing the + ``CALL``. + * Ensure ``make_inputargs`` fails properly when given arguments with type + information + * Makes ``optimiseopt`` iterative instead of recursive so it can be reasoned + about more easily and debugging is faster + * Refactor and remove dead code from ``optimizeopt``, ``resume`` + + +.. _resolved: http://doc.pypy.org/en/latest/whatsnew-5.6.0.html + +Please update, and continue to help us make PyPy better. + +Cheers 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 @@ -110,4 +110,4 @@ "hg log -r %s --template '{branch}'" % startrev) if errcode != 0: py.test.skip('no Mercurial repo') - assert wc_branch == 'default' + assert wc_branch in ('default', "'default'") # sometimes the ' leaks (windows) diff --git a/pypy/doc/tool/makecontributor.py b/pypy/doc/tool/makecontributor.py --- a/pypy/doc/tool/makecontributor.py +++ b/pypy/doc/tool/makecontributor.py @@ -32,7 +32,7 @@ 'Niklaus Haldimann': ['nik'], 'Alexander Schremmer': ['xoraxax'], 'Anders Hammarquist': ['iko'], - 'David Edelsohn': ['edelsoh', 'edelsohn'], + 'David Edelsohn': ['edelsoh', 'edelsohn','opassembler.py'], 'Niko Matsakis': ['niko'], 'Jakub Gustak': ['jlg'], 'Guido Wesdorp': ['guido'], @@ -75,6 +75,9 @@ 'Spenser Bauman':['Spenser Andrew Bauman'], 'Raffael Tfirst':['raffael.tfi...@gmail.com'], 'timo':['t...@eistee.fritz.box'], + 'Jasper Schulz':['Jasper.Schulz'], + 'Aaron Gallagher':['"Aaron Gallagher'], + 'Yasir Suhail':['yasirs'], } alias_map = {} 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 @@ -1,82 +1,12 @@ ========================== -What's new in PyPy2.7 5.4+ +What's new in PyPy2.7 5.6+ ========================== -.. this is a revision shortly after release-pypy2.7-v5.4 -.. startrev: 522736f816dc +.. this is a revision shortly after release-pypy2.7-v5.6 +.. startrev: 7e9787939641 -.. branch: rpython-resync -Backport rpython changes made directly on the py3k and py3.5 branches. +.. branch: rpython-error-to-systemerror -.. branch: buffer-interface -Implement PyObject_GetBuffer, PyMemoryView_GET_BUFFER, and handles memoryviews -in numpypy - -.. branch: force-virtual-state -Improve merging of virtual states in the JIT in order to avoid jumping to the -preamble. Accomplished by allocating virtual objects where non-virtuals are -expected. - -.. branch: conditional_call_value_3 -JIT residual calls: if the called function starts with a fast-path -like "if x.foo != 0: return x.foo", then inline the check before -doing the CALL. For now, string hashing is about the only case. - -.. branch: search-path-from-libpypy - -The compiled pypy now looks for its lib-python/lib_pypy path starting -from the location of the *libpypy-c* instead of the executable. This is -arguably more consistent, and also it is what occurs anyway if you're -embedding pypy. Linux distribution packagers, take note! At a minimum, -the ``libpypy-c.so`` must really be inside the path containing -``lib-python`` and ``lib_pypy``. Of course, you can put a symlink to it -from somewhere else. You no longer have to do the same with the -``pypy`` executable, as long as it finds its ``libpypy-c.so`` library. - -.. branch: _warnings - -CPython allows warning.warn(('something', 1), Warning), on PyPy this -produced a "expected a readable buffer object" error. Test and fix. - -.. branch: stricter-strip - -CPython rejects 'a'.strip(buffer(' ')); only None, str or unicode are -allowed as arguments. Test and fix for str and unicode - -.. branch: faulthandler - -Port the 'faulthandler' module to PyPy default. This module is standard -in Python 3.3 but can also be installed from CPython >= 2.6 from PyPI. - -.. branch: test-cpyext - -Refactor cpyext testing to be more pypy3-friendly. - -.. branch: better-error-missing-self - -Improve the error message when the user forgot the "self" argument of a method. - - -.. fb6bb835369e -Change the ``timeit`` module: it now prints the average time and the standard -deviation over 7 runs by default, instead of the minimum. The minimum is often -misleading. - -.. branch: unrecursive-opt - -Make optimiseopt iterative instead of recursive so it can be reasoned about -more easily and debugging is faster. - -.. branch: Tiberiumk/fix-2412-1476011166874 -.. branch: redirect-assembler-jitlog - - - -.. branch: stdlib-2.7.12 - -Update stdlib to version 2.7.12 - -.. branch: buffer-interface2 - -Improve support for new buffer interface in cpyext, bf_getbuffer on built-in -types still missing +Any uncaught RPython exception (from a PyPy bug) is turned into an +app-level SystemError. This should improve the lot of users hitting an +uncaught RPython error. diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-pypy2-5.6.0.rst copy from pypy/doc/whatsnew-head.rst copy to pypy/doc/whatsnew-pypy2-5.6.0.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-pypy2-5.6.0.rst @@ -1,6 +1,6 @@ -========================== -What's new in PyPy2.7 5.4+ -========================== +========================= +What's new in PyPy2.7 5.6 +========================= .. this is a revision shortly after release-pypy2.7-v5.4 .. startrev: 522736f816dc @@ -80,3 +80,28 @@ Improve support for new buffer interface in cpyext, bf_getbuffer on built-in types still missing + + +.. branch: fix-struct-unpack-Q + +Improve compatibility with CPython in the ``struct`` module. In particular, +``struct.unpack`` now returns an ``int`` whenever the returned value fits, +while previously it always returned a ``long`` for certains format codes such +as ``Q`` (and also ``I``, ``L`` and ``q`` on 32 bit) + +.. branch: zarch-simd-support + +s390x implementation for vector operations used in VecOpt + +.. branch: ppc-vsx-support + +PowerPC implementation for vector operations used in VecOpt + +.. branch: newinitwarn + +Match CPython's stricter handling of __new/init__ arguments + +.. branch: openssl-1.1 + +Support for OpenSSL version 1.1 (in addition to version 1.0). +Tested on Linux (1.1, 1.0), on Win32, and Mac (1.0 only) diff --git a/pypy/doc/windows.rst b/pypy/doc/windows.rst --- a/pypy/doc/windows.rst +++ b/pypy/doc/windows.rst @@ -20,6 +20,22 @@ .. _our downloads: http://pypy.org/download.html +Installing Visual Compiler v9 (for Python 2.7) +---------------------------------------------- + +This compiler, while the standard one for Python 2.7, is depricated. Microsoft has +made it available as the `Microsoft Visual C++ Compiler for Python 2.7`_ (the link +was checked in Nov 2016). Note that the compiler suite will be installed in +``C:\Users\<user name>\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python``. +Using a current version of ``setuptools`` will be able to find it there. For +Windows 10, you must right-click the download, and under ``Properties`` -> +``Compatibility`` mark it as ``Run run this program in comatibility mode for`` +``Previous version...``. Also, you must download and install the ``.Net Framework 3.5``, +otherwise ``mt.exe`` will silently fail. Installation will begin automatically +by running the mt.exe command by hand from a DOS window (that is how the author +discovered the problem). + +.. _Microsoft Visual C++ Compiler for Python 2.7: https://www.microsoft.com/en-us/download/details.aspx?id=44266 Translating PyPy with Visual Studio ----------------------------------- diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py --- a/pypy/goal/targetpypystandalone.py +++ b/pypy/goal/targetpypystandalone.py @@ -33,7 +33,12 @@ 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')) withjit = space.config.objspace.usemodules.pypyjit + else: + w_initstdio = space.appexec([], """(): + return lambda unbuffered: None + """) def entry_point(argv): if withjit: @@ -103,18 +108,23 @@ " not found in %s or in any parent directory" % home1) return rffi.cast(rffi.INT, 1) space.startup() - space.appexec([w_path], """(path): - import sys - sys.path[:] = path - """) - # import site + must_leave = space.threadlocals.try_enter_thread(space) try: - space.setattr(space.getbuiltinmodule('sys'), - space.wrap('executable'), - space.wrap(home)) - import_ = space.getattr(space.getbuiltinmodule('__builtin__'), - space.wrap('__import__')) - space.call_function(import_, space.wrap('site')) + # 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], + r"""(path, home, initstdio): + import sys + sys.path[:] = path + sys.executable = home + initstdio(unbuffered=True) + try: + import site + except Exception as e: + sys.stderr.write("'import site' failed:\n") + import traceback + traceback.print_exc() + """) return rffi.cast(rffi.INT, 0) except OperationError as e: if verbose: @@ -122,6 +132,9 @@ debug(" operror-type: " + e.w_type.getname(space)) debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space)))) return rffi.cast(rffi.INT, -1) + finally: + if must_leave: + space.threadlocals.leave_thread(space) @entrypoint_highlevel('main', [rffi.CCHARP], c_name='pypy_execute_source') def pypy_execute_source(ll_source): @@ -240,7 +253,8 @@ raise Exception("Cannot use the --output option with PyPy " "when --shared is on (it is by default). " "See issue #1971.") - if config.translation.profopt is not None: + if (config.translation.profopt is not None + and not config.translation.noprofopt): raise Exception("Cannot use the --profopt option " "when --shared is on (it is by default). " "See issue #2398.") diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py --- a/pypy/interpreter/app_main.py +++ b/pypy/interpreter/app_main.py @@ -275,6 +275,10 @@ def set_fully_buffered_io(): sys.stdout = sys.__stdout__ = fdopen(1, 'w') +def initstdio(unbuffered=False): + if unbuffered: + set_unbuffered_io() + # ____________________________________________________________ # Main entry point diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py --- a/pypy/interpreter/error.py +++ b/pypy/interpreter/error.py @@ -7,6 +7,7 @@ from rpython.rlib import jit from rpython.rlib.objectmodel import we_are_translated, specialize +from rpython.rlib import rstackovf from pypy.interpreter import debug @@ -58,10 +59,14 @@ def __str__(self): "NOT_RPYTHON: Convenience for tracebacks." s = self._w_value - if self.__class__ is not OperationError and s is None: - space = getattr(self.w_type, 'space') - if space is not None: + space = getattr(self.w_type, 'space', None) + if space is not None: + if self.__class__ is not OperationError and s is None: s = self._compute_value(space) + try: + s = space.str_w(s) + except Exception: + pass return '[%s: %s]' % (self.w_type, s) def errorstr(self, space, use_repr=False): @@ -73,11 +78,8 @@ exc_value = str(w_value) else: w = space.wrap - if space.is_w(space.type(self.w_type), space.w_str): - exc_typename = space.str_w(self.w_type) - else: - exc_typename = space.str_w( - space.getattr(self.w_type, w('__name__'))) + exc_typename = space.str_w( + space.getattr(self.w_type, w('__name__'))) if space.is_w(w_value, space.w_None): exc_value = "" else: @@ -508,3 +510,47 @@ if module: space.setattr(w_exc, space.wrap("__module__"), space.wrap(module)) return w_exc + +@jit.dont_look_inside +def get_converted_unexpected_exception(space, e): + """This is used in two places when we get an non-OperationError + RPython exception: from gateway.py when calling an interp-level + function raises; and from pyopcode.py when we're exiting the + interpretation of the frame with an exception. Note that it + *cannot* be used in pyopcode.py: that place gets a + ContinueRunningNormally exception from the JIT, which must not end + up here! + """ + try: + if not we_are_translated(): + raise + raise e + except KeyboardInterrupt: + return OperationError(space.w_KeyboardInterrupt, space.w_None) + except MemoryError: + return OperationError(space.w_MemoryError, space.w_None) + except rstackovf.StackOverflow as e: + # xxx twisted logic which happens to give the result that we + # want: when untranslated, a RuntimeError or its subclass + # NotImplementedError is caught here. Then + # check_stack_overflow() will re-raise it directly. We see + # the result as this exception propagates directly. But when + # translated, an RPython-level RuntimeError is turned into + # an app-level RuntimeError by the next case. + rstackovf.check_stack_overflow() + return oefmt(space.w_RuntimeError, + "maximum recursion depth exceeded") + except RuntimeError: # not on top of py.py + return OperationError(space.w_RuntimeError, space.w_None) + except: + if we_are_translated(): + from rpython.rlib.debug import debug_print_traceback + debug_print_traceback() + extra = '; internal traceback was dumped to stderr' + else: + # when untranslated, we don't wrap into an app-level + # SystemError (this makes debugging tests harder) + raise + return OperationError(space.w_SystemError, space.wrap( + "unexpected internal exception (please report a bug): %r%s" % + (e, extra))) diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py --- a/pypy/interpreter/function.py +++ b/pypy/interpreter/function.py @@ -611,7 +611,7 @@ class StaticMethod(W_Root): """The staticmethod objects.""" - _immutable_fields_ = ['w_function'] + _immutable_fields_ = ['w_function?'] def __init__(self, w_function): self.w_function = w_function @@ -622,13 +622,16 @@ def descr_staticmethod__new__(space, w_subtype, w_function): instance = space.allocate_instance(StaticMethod, w_subtype) - instance.__init__(w_function) - return space.wrap(instance) + instance.__init__(space.w_None) + return instance + + def descr_init(self, space, w_function): + self.w_function = w_function class ClassMethod(W_Root): """The classmethod objects.""" - _immutable_fields_ = ['w_function'] + _immutable_fields_ = ['w_function?'] def __init__(self, w_function): self.w_function = w_function @@ -641,8 +644,11 @@ def descr_classmethod__new__(space, w_subtype, w_function): instance = space.allocate_instance(ClassMethod, w_subtype) - instance.__init__(w_function) - return space.wrap(instance) + instance.__init__(space.w_None) + return instance + + def descr_init(self, space, w_function): + self.w_function = w_function class FunctionWithFixedCode(Function): can_change_code = False diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py --- a/pypy/interpreter/gateway.py +++ b/pypy/interpreter/gateway.py @@ -23,7 +23,6 @@ DescrMismatch) from pypy.interpreter.error import OperationError, oefmt from pypy.interpreter.function import ClassMethod, FunctionWithFixedCode -from rpython.rlib import rstackovf from rpython.rlib.objectmodel import we_are_translated from rpython.rlib.rarithmetic import r_longlong, r_int, r_ulonglong, r_uint from rpython.tool.sourcetools import func_with_new_name, compile2 @@ -712,16 +711,11 @@ if not we_are_translated(): raise raise e - except KeyboardInterrupt: - raise OperationError(space.w_KeyboardInterrupt, space.w_None) - except MemoryError: - raise OperationError(space.w_MemoryError, space.w_None) - except rstackovf.StackOverflow as e: - rstackovf.check_stack_overflow() - raise oefmt(space.w_RuntimeError, - "maximum recursion depth exceeded") - except RuntimeError: # not on top of py.py - raise OperationError(space.w_RuntimeError, space.w_None) + except OperationError: + raise + except Exception as e: # general fall-back + from pypy.interpreter import error + raise error.get_converted_unexpected_exception(space, e) # (verbose) performance hack below diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py --- a/pypy/interpreter/pyframe.py +++ b/pypy/interpreter/pyframe.py @@ -1,6 +1,7 @@ """ PyFrame class implementation with the interpreter main loop. """ +import sys from rpython.rlib import jit from rpython.rlib.debug import make_sure_not_resized, check_nonneg from rpython.rlib.jit import hint @@ -278,6 +279,10 @@ self.pushvalue(w_inputvalue) w_exitvalue = self.dispatch(self.pycode, next_instr, executioncontext) + except OperationError: + raise + except Exception as e: # general fall-back + raise self._convert_unexpected_exception(e) finally: executioncontext.return_trace(self, w_exitvalue) # it used to say self.last_exception = None @@ -883,6 +888,14 @@ frame = frame.f_backref() return None + def _convert_unexpected_exception(self, e): + from pypy.interpreter import error + + operr = error.get_converted_unexpected_exception(self.space, e) + pytraceback.record_application_traceback( + self.space, operr, self, self.last_instr) + raise operr + # ____________________________________________________________ def get_block_class(opname): diff --git a/pypy/interpreter/test/test_executioncontext.py b/pypy/interpreter/test/test_executioncontext.py --- a/pypy/interpreter/test/test_executioncontext.py +++ b/pypy/interpreter/test/test_executioncontext.py @@ -1,8 +1,10 @@ import py from pypy.interpreter import executioncontext +from pypy.interpreter.error import OperationError -class Finished(Exception): - pass +class Finished(OperationError): + def __init__(self): + OperationError.__init__(self, "exception_class", "exception_value") class TestExecutionContext: diff --git a/pypy/interpreter/test/test_gateway.py b/pypy/interpreter/test/test_gateway.py --- a/pypy/interpreter/test/test_gateway.py +++ b/pypy/interpreter/test/test_gateway.py @@ -4,6 +4,7 @@ from pypy.interpreter import gateway, argument from pypy.interpreter.gateway import ObjSpace, W_Root, WrappedDefault from pypy.interpreter.signature import Signature +from pypy.interpreter.error import OperationError import py import sys @@ -771,6 +772,42 @@ w_g = space.wrap(gateway.interp2app_temp(g, doc='bar')) assert space.unwrap(space.getattr(w_g, space.wrap('__doc__'))) == 'bar' + def test_system_error(self): + py.test.skip("we don't wrap a random exception inside SystemError " + "when untranslated, because it makes testing harder") + class UnexpectedException(Exception): + pass + space = self.space + def g(space): + raise UnexpectedException + w_g = space.wrap(gateway.interp2app_temp(g)) + e = py.test.raises(OperationError, space.appexec, [w_g], """(my_g): + my_g() + """) + err = str(e.value) + assert 'SystemError' in err + assert ('unexpected internal exception (please ' + 'report a bug): UnexpectedException') in err + + def test_system_error_2(self): + py.test.skip("we don't wrap a random exception inside SystemError " + "when untranslated, because it makes testing harder") + class UnexpectedException(Exception): + pass + space = self.space + def g(space): + raise UnexpectedException + w_g = space.wrap(gateway.interp2app_temp(g)) + w_msg = space.appexec([w_g], """(my_g): + try: + my_g() + except SystemError as e: + return str(e) + """) + err = space.str_w(w_msg) + assert ('unexpected internal exception (please ' + 'report a bug): UnexpectedException') in err + class AppTestPyTestMark: @py.test.mark.unlikely_to_exist diff --git a/pypy/interpreter/test/test_targetpypy.py b/pypy/interpreter/test/test_targetpypy.py --- a/pypy/interpreter/test/test_targetpypy.py +++ b/pypy/interpreter/test/test_targetpypy.py @@ -20,7 +20,7 @@ space.wrap('modules')), space.wrap('xyz'))) assert x == 3 - lls = rffi.str2charp("sys") + lls = rffi.str2charp("sys # should give a NameError") execute_source(lls) lltype.free(lls, flavor='raw') # did not crash - the same globals diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py --- a/pypy/interpreter/typedef.py +++ b/pypy/interpreter/typedef.py @@ -106,8 +106,10 @@ # So we create a few interp-level subclasses of W_XxxObject, which add # some combination of features. This is done using mapdict. -# we need two subclasses of the app-level type, one to add mapdict, and then one -# to add del to not slow down the GC. +# Note that nowadays, we need not "a few" but only one subclass. It +# adds mapdict, which flexibly allows all features. We handle the +# presence or absence of an app-level '__del__' by calling +# register_finalizer() or not. @specialize.memo() def get_unique_interplevel_subclass(space, cls): @@ -686,15 +688,17 @@ (e.g. C().f()). The instance is ignored except for its class.""", __get__ = interp2app(StaticMethod.descr_staticmethod_get), __new__ = interp2app(StaticMethod.descr_staticmethod__new__.im_func), + __init__=interp2app(StaticMethod.descr_init), __func__= interp_attrproperty_w('w_function', cls=StaticMethod), ) ClassMethod.typedef = TypeDef( 'classmethod', - __new__ = interp2app(ClassMethod.descr_classmethod__new__.im_func), - __get__ = interp2app(ClassMethod.descr_classmethod_get), - __func__= interp_attrproperty_w('w_function', cls=ClassMethod), - __doc__ = """classmethod(function) -> class method + __new__=interp2app(ClassMethod.descr_classmethod__new__.im_func), + __init__=interp2app(ClassMethod.descr_init), + __get__=interp2app(ClassMethod.descr_classmethod_get), + __func__=interp_attrproperty_w('w_function', cls=ClassMethod), + __doc__="""classmethod(function) -> class method Convert a function to be a class method. diff --git a/pypy/module/__builtin__/test/test_builtin.py b/pypy/module/__builtin__/test/test_builtin.py --- a/pypy/module/__builtin__/test/test_builtin.py +++ b/pypy/module/__builtin__/test/test_builtin.py @@ -509,59 +509,6 @@ assert eval("i", None, None) == 4 assert eval('a', None, dict(a=42)) == 42 - def test_compile(self): - co = compile('1+2', '?', 'eval') - assert eval(co) == 3 - co = compile(buffer('1+2'), '?', 'eval') - assert eval(co) == 3 - exc = raises(TypeError, compile, chr(0), '?', 'eval') - assert str(exc.value) == "compile() expected string without null bytes" - exc = raises(TypeError, compile, unichr(0), '?', 'eval') - assert str(exc.value) == "compile() expected string without null bytes" - exc = raises(TypeError, compile, memoryview('1+2'), '?', 'eval') - assert str(exc.value) == "expected a readable buffer object" - compile("from __future__ import with_statement", "<test>", "exec") - raises(SyntaxError, compile, '-', '?', 'eval') - raises(ValueError, compile, '"\\xt"', '?', 'eval') - raises(ValueError, compile, '1+2', '?', 'maybenot') - raises(ValueError, compile, "\n", "<string>", "exec", 0xff) - raises(TypeError, compile, '1+2', 12, 34) - - def test_compile_error_message(self): - import re - compile('# -*- coding: iso-8859-15 -*-\n', 'dummy', 'exec') - compile(b'\xef\xbb\xbf\n', 'dummy', 'exec') - compile(b'\xef\xbb\xbf# -*- coding: utf-8 -*-\n', 'dummy', 'exec') - exc = raises(SyntaxError, compile, - b'# -*- coding: fake -*-\n', 'dummy', 'exec') - assert 'fake' in str(exc.value) - exc = raises(SyntaxError, compile, - b'\xef\xbb\xbf# -*- coding: iso-8859-15 -*-\n', 'dummy', 'exec') - assert 'iso-8859-15' in str(exc.value) - assert 'BOM' in str(exc.value) - exc = raises(SyntaxError, compile, - b'\xef\xbb\xbf# -*- coding: fake -*-\n', 'dummy', 'exec') - assert 'fake' in str(exc.value) - assert 'BOM' in str(exc.value) - - def test_unicode_compile(self): - try: - compile(u'-', '?', 'eval') - except SyntaxError as e: - assert e.lineno == 1 - - def test_unicode_encoding_compile(self): - code = u"# -*- coding: utf-8 -*-\npass\n" - raises(SyntaxError, compile, code, "tmp", "exec") - - def test_recompile_ast(self): - import _ast - # raise exception when node type doesn't match with compile mode - co1 = compile('print 1', '<string>', 'exec', _ast.PyCF_ONLY_AST) - raises(TypeError, compile, co1, '<ast>', 'eval') - co2 = compile('1+1', '<string>', 'eval', _ast.PyCF_ONLY_AST) - compile(co2, '<ast>', 'eval') - def test_isinstance(self): assert isinstance(5, int) assert isinstance(5, object) @@ -624,34 +571,10 @@ raises(TypeError, hasattr, x, 42) raises(UnicodeError, hasattr, x, u'\u5678') # cannot encode attr name - def test_compile_leading_newlines(self): - src = """ -def fn(): pass -""" - co = compile(src, 'mymod', 'exec') - firstlineno = co.co_firstlineno - assert firstlineno == 2 - - def test_compile_null_bytes(self): - raises(TypeError, compile, '\x00', 'mymod', 'exec', 0) - src = "#abc\x00def\n" - raises(TypeError, compile, src, 'mymod', 'exec') - raises(TypeError, compile, src, 'mymod', 'exec', 0) + def test_execfile_args(self): execfile(self.nullbytes) # works - - def test_execfile_args(self): raises(TypeError, execfile, self.nonexistent, {}, ()) - def test_compile_null_bytes_flag(self): - try: - from _ast import PyCF_ACCEPT_NULL_BYTES - except ImportError: - skip('PyPy only (requires _ast.PyCF_ACCEPT_NULL_BYTES)') - raises(SyntaxError, compile, '\x00', 'mymod', 'exec', - PyCF_ACCEPT_NULL_BYTES) - src = "#abc\x00def\n" - compile(src, 'mymod', 'exec', PyCF_ACCEPT_NULL_BYTES) # works - def test_print_function(self): import __builtin__ import sys diff --git a/pypy/module/__builtin__/test/test_compile.py b/pypy/module/__builtin__/test/test_compile.py new file mode 100644 --- /dev/null +++ b/pypy/module/__builtin__/test/test_compile.py @@ -0,0 +1,77 @@ +class AppTestCompile: + def test_simple(self): + co = compile('1+2', '?', 'eval') + assert eval(co) == 3 + co = compile(buffer('1+2'), '?', 'eval') + assert eval(co) == 3 + exc = raises(TypeError, compile, chr(0), '?', 'eval') + assert str(exc.value) == "compile() expected string without null bytes" + exc = raises(TypeError, compile, unichr(0), '?', 'eval') + assert str(exc.value) == "compile() expected string without null bytes" + exc = raises(TypeError, compile, memoryview('1+2'), '?', 'eval') + assert str(exc.value) == "expected a readable buffer object" + compile("from __future__ import with_statement", "<test>", "exec") + raises(SyntaxError, compile, '-', '?', 'eval') + raises(ValueError, compile, '"\\xt"', '?', 'eval') + raises(ValueError, compile, '1+2', '?', 'maybenot') + raises(ValueError, compile, "\n", "<string>", "exec", 0xff) + raises(TypeError, compile, '1+2', 12, 34) + + def test_error_message(self): + import re + compile('# -*- coding: iso-8859-15 -*-\n', 'dummy', 'exec') + compile(b'\xef\xbb\xbf\n', 'dummy', 'exec') + compile(b'\xef\xbb\xbf# -*- coding: utf-8 -*-\n', 'dummy', 'exec') + exc = raises(SyntaxError, compile, + b'# -*- coding: fake -*-\n', 'dummy', 'exec') + assert 'fake' in str(exc.value) + exc = raises(SyntaxError, compile, + b'\xef\xbb\xbf# -*- coding: iso-8859-15 -*-\n', 'dummy', 'exec') + assert 'iso-8859-15' in str(exc.value) + assert 'BOM' in str(exc.value) + exc = raises(SyntaxError, compile, + b'\xef\xbb\xbf# -*- coding: fake -*-\n', 'dummy', 'exec') + assert 'fake' in str(exc.value) + assert 'BOM' in str(exc.value) + + def test_unicode(self): + try: + compile(u'-', '?', 'eval') + except SyntaxError as e: + assert e.lineno == 1 + + def test_unicode_encoding(self): + code = u"# -*- coding: utf-8 -*-\npass\n" + raises(SyntaxError, compile, code, "tmp", "exec") + + def test_recompile_ast(self): + import _ast + # raise exception when node type doesn't match with compile mode + co1 = compile('print 1', '<string>', 'exec', _ast.PyCF_ONLY_AST) + raises(TypeError, compile, co1, '<ast>', 'eval') + co2 = compile('1+1', '<string>', 'eval', _ast.PyCF_ONLY_AST) + compile(co2, '<ast>', 'eval') + + def test_leading_newlines(self): + src = """ +def fn(): pass +""" + co = compile(src, 'mymod', 'exec') + firstlineno = co.co_firstlineno + assert firstlineno == 2 + + def test_null_bytes(self): + raises(TypeError, compile, '\x00', 'mymod', 'exec', 0) + src = "#abc\x00def\n" + raises(TypeError, compile, src, 'mymod', 'exec') + raises(TypeError, compile, src, 'mymod', 'exec', 0) + + def test_null_bytes_flag(self): + try: + from _ast import PyCF_ACCEPT_NULL_BYTES + except ImportError: + skip('PyPy only (requires _ast.PyCF_ACCEPT_NULL_BYTES)') + raises(SyntaxError, compile, '\x00', 'mymod', 'exec', + PyCF_ACCEPT_NULL_BYTES) + src = "#abc\x00def\n" + compile(src, 'mymod', 'exec', PyCF_ACCEPT_NULL_BYTES) # works 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 @@ -20,6 +20,12 @@ x = Static(1) assert isinstance(x, Static) + class C(Static): + def __init__(self, callable): + super(C, self).__init__(callable) + y = C(1) + assert isinstance(y, C) + def test_classmethod(self): class C(object): def f(cls, stuff): @@ -41,8 +47,14 @@ x = Classm(1) assert isinstance(x, Classm) + class C(Classm): + def __init__(self, callable): + super(C, self).__init__(callable) + y = C(1) + assert isinstance(y, C) + def test_property_simple(self): - + class a(object): def _get(self): return 42 def _set(self, value): raise AttributeError @@ -98,7 +110,7 @@ assert message.startswith('super(type, obj): obj must be an instance or subtype of type') def test_super_various(self): - + class A(object): def meth(self, a): return "A(%r)" % a @@ -352,10 +364,10 @@ def test_property_subclass_with_init(self): l = [] - + def x(self): l.append('x') - + class P(property): def __init__(self): property.__init__(self, x) diff --git a/pypy/module/__pypy__/interp_magic.py b/pypy/module/__pypy__/interp_magic.py --- a/pypy/module/__pypy__/interp_magic.py +++ b/pypy/module/__pypy__/interp_magic.py @@ -86,7 +86,9 @@ return space.w_None return space.get(w_descr, w_obj) -def do_what_I_mean(space): +def do_what_I_mean(space, w_crash=None): + if not space.is_none(w_crash): + raise ValueError # RPython-level, uncaught return space.wrap(42) diff --git a/pypy/module/__pypy__/test/test_special.py b/pypy/module/__pypy__/test/test_special.py --- a/pypy/module/__pypy__/test/test_special.py +++ b/pypy/module/__pypy__/test/test_special.py @@ -135,9 +135,19 @@ class AppTestJitFeatures(object): spaceconfig = {"translation.jit": True} + def setup_class(cls): + cls.w_runappdirect = cls.space.wrap(cls.runappdirect) + def test_jit_backend_features(self): from __pypy__ import jit_backend_features supported_types = jit_backend_features assert isinstance(supported_types, list) for x in supported_types: assert x in ['floats', 'singlefloats', 'longlong'] + + def test_do_what_I_mean_error(self): + if not self.runappdirect: + skip("we don't wrap a random exception inside SystemError " + "when untranslated, because it makes testing harder") + from __pypy__ import do_what_I_mean + raises(SystemError, do_what_I_mean, 1) 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, entrypoint from rpython.rtyper.lltypesystem import rffi _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit