Author: Matti Picus <matti.pi...@gmail.com> Branch: unicode-utf8-py3 Changeset: r95770:0c7880912bd4 Date: 2019-02-01 15:52 +0200 http://bitbucket.org/pypy/pypy/changeset/0c7880912bd4/
Log: merge py3.5 into branch diff --git a/LICENSE b/LICENSE --- a/LICENSE +++ b/LICENSE @@ -40,16 +40,16 @@ Armin Rigo Maciej Fijalkowski Carl Friedrich Bolz-Tereick + Antonio Cuni Amaury Forgeot d'Arc - Antonio Cuni Matti Picus Samuele Pedroni Ronan Lamy Alex Gaynor Philip Jenvey + Richard Plangger Brian Kearns - Richard Plangger - Michael Hudson + Michael Hudson-Doyle Manuel Jacob David Schneider Holger Krekel @@ -59,8 +59,8 @@ Anders Chrigstrom Wim Lavrijsen Eric van Riet Paap + Remi Meier Richard Emslie - Remi Meier Alexander Schremmer Dan Villiom Podlaski Christiansen Lukas Diekmann @@ -70,10 +70,10 @@ Niklaus Haldimann Camillo Bruni Laura Creighton - Romain Guillebert Toon Verwaest Leonardo Santagada Seo Sanghyeon + Romain Guillebert Ronny Pfannschmidt Justin Peel Raffael Tfirst @@ -114,12 +114,12 @@ Squeaky Edd Barrett Timo Paulssen + Laurence Tratt Marius Gedminas Nicolas Truessel Alexandre Fayolle Simon Burton Martin Matusiak - Laurence Tratt Wenzhu Man Konstantin Lopuhin John Witulski @@ -134,8 +134,9 @@ Jean-Philippe St. Pierre Guido van Rossum Pavel Vinogradov + Stefan Beyer + William Leslie Paweł Piotr Przeradowski - William Leslie marky1991 Ilya Osadchiy Tobias Oberstein @@ -144,10 +145,10 @@ Taavi Burns Adrian Kuhn tav + Stian Andreassen Georg Brandl Joannah Nanjekye Bert Freudenberg - Stian Andreassen Wanja Saatkamp Mike Blume Gerald Klix @@ -163,6 +164,7 @@ Vasily Kuznetsov Preston Timmons David Ripton + Pieter Zieschang Dusty Phillips Lukas Renggli Guenter Jantzen @@ -176,6 +178,7 @@ Andrew Durdin Ben Young Michael Schneider + Yusuke Tsutsumi Nicholas Riley Jason Chu Igor Trindade Oliveira @@ -187,7 +190,6 @@ Mariano Anaya anatoly techtonik Karl Bartel - Stefan Beyer Gabriel Lavoie Jared Grubb Alecsandru Patrascu @@ -198,7 +200,6 @@ Victor Stinner Andrews Medina Aaron Iles - p_ziesch...@yahoo.de Toby Watson Daniel Patrick Stuart Williams @@ -210,6 +211,7 @@ Mikael Schönenberg Stanislaw Halik Mihnea Saracin + Matt Jackson Berkin Ilbeyi Gasper Zejn Faye Zhao @@ -217,12 +219,14 @@ Anders Qvist Corbin Simpson Chirag Jadwani + Pauli Virtanen Jonathan David Riehl Beatrice During Alex Perry Robert Zaremba Alan McIntyre Alexander Sedov + David C Ellis Vaibhav Sood Reuben Cummings Attila Gobi @@ -242,7 +246,6 @@ Arjun Naik Aaron Gallagher Alexis Daboville - Pieter Zieschang Karl Ramm Lukas Vacek Omer Katz @@ -270,12 +273,15 @@ Catalin Gabriel Manciu Jacob Oscarson Ryan Gonzalez + Antoine Dupre Kristjan Valur Jonsson Lucio Torre Richard Lancaster Dan Buch Lene Wagner Tomo Cocoa + Miro Hrončok + Anthony Sottile David Lievens Neil Blakey-Milner Henrik Vendelbo @@ -290,10 +296,12 @@ Bobby Impollonia Roberto De Ioris Jeong YunWon + andrewjlawrence Christopher Armstrong Aaron Tubbs Vasantha Ganesh K Jason Michalski + Radu Ciorba Markus Holtermann Andrew Thompson Yusei Tahara @@ -301,28 +309,26 @@ Fabio Niephaus Akira Li Gustavo Niemeyer - Rafał Gałczyński + Nate Bragg Lucas Stadler roberto@goyle + Carl Bordum Hansen Matt Bogosian Yury V. Zaytsev florinpapa Anders Sigfridsson - Matt Jackson Nikolay Zinov rafalgalczyn...@gmail.com Joshua Gilbert Anna Katrina Dominguez Kim Jin Su Amber Brown - Miro Hrončok - Anthony Sottile - Nate Bragg + Andrew Stepanov + Rafał Gałczyński Ben Darnell Juan Francisco Cantero Hurtado Godefroid Chappelle Julian Berman - Michael Hudson-Doyle Stephan Busemann Dan Colish timo @@ -332,6 +338,7 @@ halgari Jim Baker Chris Lambacher + John Aldis coolbutusel...@gmail.com Mike Bayer Rodrigo Araújo @@ -340,6 +347,7 @@ OlivierBlanvillain Jonas Pfannschmidt Zearin + Johan Forsberg Andrey Churin Dan Crosta reub...@gmail.com @@ -349,8 +357,9 @@ Steve Papanik Eli Stevens Boglarka Vezer - gabrielg + gabri...@ec2-54-146-239-158.compute-1.amazonaws.com PavloKapyshin + Hervé Beraud Tomer Chachamu Christopher Groskopf Asmo Soinio @@ -364,7 +373,6 @@ Michael Chermside Anna Ravencroft remarkablerocket - Pauli Virtanen Petre Vijiac Berker Peksag Christian Muirhead @@ -384,12 +392,13 @@ Zooko Wilcox-O Hearn James Lan jiaaro + Evgenii Gorinov Markus Unterwaditzer Kristoffer Kleine Graham Markall Dan Loewenherz werat - Andrew Stepanov + Filip Salomonsson Niclas Olofsson Chris Pressey Tobias Diaz diff --git a/extra_tests/cffi_tests/cffi0/test_function.py b/extra_tests/cffi_tests/cffi0/test_function.py --- a/extra_tests/cffi_tests/cffi0/test_function.py +++ b/extra_tests/cffi_tests/cffi0/test_function.py @@ -46,14 +46,15 @@ assert x != math.sin(1.23) # rounding effects assert abs(x - math.sin(1.23)) < 1E-6 - def test_lround_no_return_value(self): + def test_getenv_no_return_value(self): # check that 'void'-returning functions work too ffi = FFI(backend=self.Backend()) ffi.cdef(""" - void lround(double x); + void getenv(char *); """) - m = ffi.dlopen(lib_m) - x = m.lround(1.23) + needs_dlopen_none() + m = ffi.dlopen(None) + x = m.getenv(b"FOO") assert x is None def test_dlopen_filename(self): diff --git a/extra_tests/cffi_tests/cffi1/test_pkgconfig.py b/extra_tests/cffi_tests/cffi1/test_pkgconfig.py new file mode 100644 --- /dev/null +++ b/extra_tests/cffi_tests/cffi1/test_pkgconfig.py @@ -0,0 +1,95 @@ +# Generated by pypy/tool/import_cffi.py +import sys +import subprocess +import py +import cffi.pkgconfig as pkgconfig +from cffi import PkgConfigError + + +def mock_call(libname, flag): + assert libname=="foobarbaz" + flags = { + "--cflags": "-I/usr/include/python3.6m -DABCD -DCFFI_TEST=1 -O42\n", + "--libs": "-L/usr/lib64 -lpython3.6 -shared\n", + } + return flags[flag] + + +def test_merge_flags(): + d1 = {"ham": [1, 2, 3], "spam" : ["a", "b", "c"], "foo" : []} + d2 = {"spam" : ["spam", "spam", "spam"], "bar" : ["b", "a", "z"]} + + pkgconfig.merge_flags(d1, d2) + assert d1 == { + "ham": [1, 2, 3], + "spam" : ["a", "b", "c", "spam", "spam", "spam"], + "bar" : ["b", "a", "z"], + "foo" : []} + + +def test_pkgconfig(): + assert pkgconfig.flags_from_pkgconfig([]) == {} + + saved = pkgconfig.call + try: + pkgconfig.call = mock_call + flags = pkgconfig.flags_from_pkgconfig(["foobarbaz"]) + finally: + pkgconfig.call = saved + assert flags == { + 'include_dirs': ['/usr/include/python3.6m'], + 'library_dirs': ['/usr/lib64'], + 'libraries': ['python3.6'], + 'define_macros': [('ABCD', None), ('CFFI_TEST', '1')], + 'extra_compile_args': ['-O42'], + 'extra_link_args': ['-shared'] + } + +class mock_subprocess: + PIPE = Ellipsis + class Popen: + def __init__(self, cmd, stdout, stderr): + if mock_subprocess.RESULT is None: + raise OSError("oops can't run") + assert cmd == ['pkg-config', '--print-errors', '--cflags', 'libfoo'] + def communicate(self): + bout, berr, rc = mock_subprocess.RESULT + self.returncode = rc + return bout, berr + +def test_call(): + saved = pkgconfig.subprocess + try: + pkgconfig.subprocess = mock_subprocess + + mock_subprocess.RESULT = None + e = py.test.raises(PkgConfigError, pkgconfig.call, "libfoo", "--cflags") + assert str(e.value) == "cannot run pkg-config: oops can't run" + + mock_subprocess.RESULT = b"", "Foo error!\n", 1 + e = py.test.raises(PkgConfigError, pkgconfig.call, "libfoo", "--cflags") + assert str(e.value) == "Foo error!" + + mock_subprocess.RESULT = b"abc\\def\n", "", 0 + e = py.test.raises(PkgConfigError, pkgconfig.call, "libfoo", "--cflags") + assert str(e.value).startswith("pkg-config --cflags libfoo returned an " + "unsupported backslash-escaped output:") + + mock_subprocess.RESULT = b"abc def\n", "", 0 + result = pkgconfig.call("libfoo", "--cflags") + assert result == "abc def\n" + + mock_subprocess.RESULT = b"abc def\n", "", 0 + result = pkgconfig.call("libfoo", "--cflags") + assert result == "abc def\n" + + if sys.version_info >= (3,): + mock_subprocess.RESULT = b"\xff\n", "", 0 + e = py.test.raises(PkgConfigError, pkgconfig.call, + "libfoo", "--cflags", encoding="utf-8") + assert str(e.value) == ( + "pkg-config --cflags libfoo returned bytes that cannot be " + "decoded with encoding 'utf-8':\nb'\\xff\\n'") + + finally: + pkgconfig.subprocess = saved diff --git a/lib-python/3/distutils/sysconfig_pypy.py b/lib-python/3/distutils/sysconfig_pypy.py --- a/lib-python/3/distutils/sysconfig_pypy.py +++ b/lib-python/3/distutils/sysconfig_pypy.py @@ -10,7 +10,7 @@ import sys import os -import imp, _imp +import _imp from distutils.errors import DistutilsPlatformError diff --git a/lib-python/3/test/test_dictviews.py b/lib-python/3/test/test_dictviews.py --- a/lib-python/3/test/test_dictviews.py +++ b/lib-python/3/test/test_dictviews.py @@ -1,9 +1,11 @@ +from test import support import copy import pickle import unittest class DictSetTest(unittest.TestCase): + @support.cpython_only def test_constructors_not_callable(self): kt = type({}.keys()) self.assertRaises(TypeError, kt, {}) diff --git a/lib_pypy/_collections.py b/lib_pypy/_collections.py --- a/lib_pypy/_collections.py +++ b/lib_pypy/_collections.py @@ -390,7 +390,7 @@ class defaultdict(dict): __slots__ = ["default_factory"] - + def __init__(self, *args, **kwds): if len(args) > 0: default_factory = args[0] @@ -401,10 +401,10 @@ default_factory = None self.default_factory = default_factory super(defaultdict, self).__init__(*args, **kwds) - + def __missing__(self, key): # from defaultdict docs - if self.default_factory is None: + if self.default_factory is None: raise KeyError(key) self[key] = value = self.default_factory() return value @@ -420,7 +420,7 @@ def copy(self): return type(self)(self.default_factory, self) - + def __copy__(self): return self.copy() @@ -438,9 +438,3 @@ """ return (type(self), (self.default_factory,), None, None, iter(self.items())) - - -try: - from _pypy_collections import OrderedDict -except ImportError: - pass 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 @@ -3,6 +3,7 @@ from .api import FFI from .error import CDefError, FFIError, VerificationError, VerificationMissing +from .error import PkgConfigError __version__ = "1.12.0" __version_info__ = (1, 12, 0) diff --git a/lib_pypy/cffi/api.py b/lib_pypy/cffi/api.py --- a/lib_pypy/cffi/api.py +++ b/lib_pypy/cffi/api.py @@ -643,6 +643,16 @@ self._assigned_source = (str(module_name), source, source_extension, kwds) + def set_source_pkgconfig(self, module_name, pkgconfig_libs, source, + source_extension='.c', **kwds): + from . import pkgconfig + if not isinstance(pkgconfig_libs, list): + raise TypeError("the pkgconfig_libs argument must be a list " + "of package names") + kwds2 = pkgconfig.flags_from_pkgconfig(pkgconfig_libs) + pkgconfig.merge_flags(kwds, kwds2) + self.set_source(module_name, source, source_extension, **kwds) + def distutils_extension(self, tmpdir='build', verbose=True): from distutils.dir_util import mkpath from .recompiler import recompile diff --git a/lib_pypy/cffi/error.py b/lib_pypy/cffi/error.py --- a/lib_pypy/cffi/error.py +++ b/lib_pypy/cffi/error.py @@ -1,8 +1,9 @@ class FFIError(Exception): - pass + __module__ = 'cffi' class CDefError(Exception): + __module__ = 'cffi' def __str__(self): try: current_decl = self.args[1] @@ -16,8 +17,15 @@ class VerificationError(Exception): """ An error raised when verification fails """ + __module__ = 'cffi' class VerificationMissing(Exception): """ An error raised when incomplete structures are passed into cdef, but no verification has been done """ + __module__ = 'cffi' + +class PkgConfigError(Exception): + """ An error raised for missing modules in pkg-config + """ + __module__ = 'cffi' diff --git a/pypy/doc/build.rst b/pypy/doc/build.rst --- a/pypy/doc/build.rst +++ b/pypy/doc/build.rst @@ -220,11 +220,12 @@ Making a debug build of PyPy ---------------------------- -If the Makefile is rerun with the lldebug or lldebug0 target, appropriate -compilation flags are added to add debug info and reduce compiler optimizations -to ``-O0`` respectively. If you stop in a debugger, you will see the -very wordy machine-generated C code from the rpython translation step, which -takes a little bit of reading to relate back to the rpython code. +Rerun the ``Makefile`` with the ``make lldebug`` or ``make lldebug0`` target, +which will build in a way that running under a debugger makes sense. +Appropriate compilation flags are added to add debug info, and for ``lldebug0`` +compiler optimizations are fully disabled. If you stop in a debugger, you will +see the very wordy machine-generated C code from the rpython translation step, +which takes a little bit of reading to relate back to the rpython code. Build cffi import libraries for the stdlib ------------------------------------------ diff --git a/pypy/doc/contributor.rst b/pypy/doc/contributor.rst --- a/pypy/doc/contributor.rst +++ b/pypy/doc/contributor.rst @@ -7,16 +7,16 @@ Armin Rigo Maciej Fijalkowski Carl Friedrich Bolz-Tereick + Antonio Cuni Amaury Forgeot d'Arc - Antonio Cuni Matti Picus Samuele Pedroni Ronan Lamy Alex Gaynor Philip Jenvey + Richard Plangger Brian Kearns - Richard Plangger - Michael Hudson + Michael Hudson-Doyle Manuel Jacob David Schneider Holger Krekel @@ -26,8 +26,8 @@ Anders Chrigstrom Wim Lavrijsen Eric van Riet Paap + Remi Meier Richard Emslie - Remi Meier Alexander Schremmer Dan Villiom Podlaski Christiansen Lukas Diekmann @@ -37,10 +37,10 @@ Niklaus Haldimann Camillo Bruni Laura Creighton - Romain Guillebert Toon Verwaest Leonardo Santagada Seo Sanghyeon + Romain Guillebert Ronny Pfannschmidt Justin Peel Raffael Tfirst @@ -81,12 +81,12 @@ Squeaky Edd Barrett Timo Paulssen + Laurence Tratt Marius Gedminas Nicolas Truessel Alexandre Fayolle Simon Burton Martin Matusiak - Laurence Tratt Wenzhu Man Konstantin Lopuhin John Witulski @@ -101,8 +101,9 @@ Jean-Philippe St. Pierre Guido van Rossum Pavel Vinogradov + Stefan Beyer + William Leslie Paweł Piotr Przeradowski - William Leslie marky1991 Ilya Osadchiy Tobias Oberstein @@ -111,10 +112,10 @@ Taavi Burns Adrian Kuhn tav + Stian Andreassen Georg Brandl Joannah Nanjekye Bert Freudenberg - Stian Andreassen Wanja Saatkamp Mike Blume Gerald Klix @@ -130,6 +131,7 @@ Vasily Kuznetsov Preston Timmons David Ripton + Pieter Zieschang Dusty Phillips Lukas Renggli Guenter Jantzen @@ -143,6 +145,7 @@ Andrew Durdin Ben Young Michael Schneider + Yusuke Tsutsumi Nicholas Riley Jason Chu Igor Trindade Oliveira @@ -154,7 +157,6 @@ Mariano Anaya anatoly techtonik Karl Bartel - Stefan Beyer Gabriel Lavoie Jared Grubb Alecsandru Patrascu @@ -165,7 +167,6 @@ Victor Stinner Andrews Medina Aaron Iles - p_ziesch...@yahoo.de Toby Watson Daniel Patrick Stuart Williams @@ -177,6 +178,7 @@ Mikael Schönenberg Stanislaw Halik Mihnea Saracin + Matt Jackson Berkin Ilbeyi Gasper Zejn Faye Zhao @@ -184,12 +186,14 @@ Anders Qvist Corbin Simpson Chirag Jadwani + Pauli Virtanen Jonathan David Riehl Beatrice During Alex Perry Robert Zaremba Alan McIntyre Alexander Sedov + David C Ellis Vaibhav Sood Reuben Cummings Attila Gobi @@ -209,7 +213,6 @@ Arjun Naik Aaron Gallagher Alexis Daboville - Pieter Zieschang Karl Ramm Lukas Vacek Omer Katz @@ -237,12 +240,15 @@ Catalin Gabriel Manciu Jacob Oscarson Ryan Gonzalez + Antoine Dupre Kristjan Valur Jonsson Lucio Torre Richard Lancaster Dan Buch Lene Wagner Tomo Cocoa + Miro Hrončok + Anthony Sottile David Lievens Neil Blakey-Milner Henrik Vendelbo @@ -257,10 +263,12 @@ Bobby Impollonia Roberto De Ioris Jeong YunWon + andrewjlawrence Christopher Armstrong Aaron Tubbs Vasantha Ganesh K Jason Michalski + Radu Ciorba Markus Holtermann Andrew Thompson Yusei Tahara @@ -268,28 +276,26 @@ Fabio Niephaus Akira Li Gustavo Niemeyer - Rafał Gałczyński + Nate Bragg Lucas Stadler roberto@goyle + Carl Bordum Hansen Matt Bogosian Yury V. Zaytsev florinpapa Anders Sigfridsson - Matt Jackson Nikolay Zinov rafalgalczyn...@gmail.com Joshua Gilbert Anna Katrina Dominguez Kim Jin Su Amber Brown - Miro Hrončok - Anthony Sottile - Nate Bragg + Andrew Stepanov + Rafał Gałczyński Ben Darnell Juan Francisco Cantero Hurtado Godefroid Chappelle Julian Berman - Michael Hudson-Doyle Stephan Busemann Dan Colish timo @@ -299,6 +305,7 @@ halgari Jim Baker Chris Lambacher + John Aldis coolbutusel...@gmail.com Mike Bayer Rodrigo Araújo @@ -307,6 +314,7 @@ OlivierBlanvillain Jonas Pfannschmidt Zearin + Johan Forsberg Andrey Churin Dan Crosta reub...@gmail.com @@ -316,8 +324,9 @@ Steve Papanik Eli Stevens Boglarka Vezer - gabrielg + gabri...@ec2-54-146-239-158.compute-1.amazonaws.com PavloKapyshin + Hervé Beraud Tomer Chachamu Christopher Groskopf Asmo Soinio @@ -331,7 +340,6 @@ Michael Chermside Anna Ravencroft remarkablerocket - Pauli Virtanen Petre Vijiac Berker Peksag Christian Muirhead @@ -351,12 +359,13 @@ Zooko Wilcox-O Hearn James Lan jiaaro + Evgenii Gorinov Markus Unterwaditzer Kristoffer Kleine Graham Markall Dan Loewenherz werat - Andrew Stepanov + Filip Salomonsson Niclas Olofsson Chris Pressey Tobias Diaz 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 @@ -16,9 +16,6 @@ How to Create a PyPy Release ++++++++++++++++++++++++++++ -Overview --------- - As a meta rule setting up issues in the tracker for items here may help not forgetting things. A set of todo files may also work. @@ -28,17 +25,54 @@ Release Steps -------------- +++++++++++++++ -* If needed, make a release branch -* Bump the - pypy version number in module/sys/version.py and in - module/cpyext/include/patchlevel.h and in doc/conf.py. The branch - will capture the revision number of this change for the release. +Make the release branch +------------------------ - 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. +This is needed only in case you are doing a new major version; if not, you can +probably reuse the existing release branch. + +We want to be able to freely merge default into the branch and vice-versa; +thus we need to do a complicate dance to avoid to patch the version number +when we do a merge:: + + $ hg up -r default + $ # edit the version to e.g. 7.0.0-final + $ hg ci + $ hg branch release-pypy2.7-7.x && hg ci + $ hg up -r default + $ # edit the version to 7.1.0-alpha0 + $ hg ci + $ hg up -r release-pypy2.7-7.x + $ hg merge default + $ # edit the version to AGAIN 7.0.0-final + $ hg ci + +Then, we need to do the same for the 3.x branch:: + + $ hg up -r py3.5 + $ hg merge default # this brings the version fo 7.1.0-alpha0 + $ hg branch release-pypy3.5-7.x + $ # edit the version to 7.0.0-final + $ hg ci + $ hg up -r py3.5 + $ hg merge release-pypy3.5-7.x + $ # edit the version to 7.1.0-alpha0 + $ hg ci + +To change the version, you need to edit three files: + + - ``module/sys/version.py`` + + - ``module/cpyext/include/patchlevel.h`` + + - ``doc/conf.py`` + + +Other steps +----------- + * Make sure the RPython builds on the buildbot pass with no failures 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-v7.0.0.rst release-v6.0.0.rst release-v5.10.1.rst release-v5.10.0.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-7.0.0.rst whatsnew-pypy2-6.0.0.rst whatsnew-pypy2-5.10.0.rst whatsnew-pypy2-5.10.0.rst @@ -41,6 +42,7 @@ .. toctree:: whatsnew-pypy3-head.rst + whatsnew-pypy3-7.0.0.rst whatsnew-pypy3-5.9.0.rst whatsnew-pypy3-5.8.0.rst whatsnew-pypy3-5.7.0.rst diff --git a/pypy/doc/interpreter.rst b/pypy/doc/interpreter.rst --- a/pypy/doc/interpreter.rst +++ b/pypy/doc/interpreter.rst @@ -156,7 +156,7 @@ environment found in `Frames`. Frames and Functions have references to a code object. Here is a list of Code attributes: -* ``co_flags`` flags if this code object has nested scopes/generators +* ``co_flags`` flags if this code object has nested scopes/generators/etc. * ``co_stacksize`` the maximum depth the stack can reach while executing the code * ``co_code`` the actual bytecode string diff --git a/pypy/doc/release-v7.0.0.rst b/pypy/doc/release-v7.0.0.rst new file mode 100644 --- /dev/null +++ b/pypy/doc/release-v7.0.0.rst @@ -0,0 +1,151 @@ +====================================================== +PyPy v7.0.0: triple release of 2.7, 3.5 and 3.6-alpha +====================================================== + +The PyPy team is proud to release the version 7.0.0 of PyPy, which includes +three different interpreters: + + - PyPy2.7, which is an interpreter supporting the syntax and the features of + Python 2.7 + + - PyPy3.5, which supports Python 3.5 + + - PyPy3.6-alpha: this is the first official release of PyPy to support 3.6 + features, although it is still considered alpha quality. + +All the interpreters are based on much the same codebase, thus the triple +release. + +Until we can work with downstream providers to distribute builds with PyPy, we +have made packages for some common packages `available as wheels`_. + +The GC `hooks`_ , which can be used to gain more insights into its +performance, has been improved and it is now possible to manually manage the +GC by using a combination of ``gc.disable`` and ``gc.collect_step``. See the +`GC blog post`_. + + +We updated the `cffi`_ module included in PyPy to version 1.12, and the +`cppyy`_ backend to 1.4. Please use these to wrap your C and C++ code, +respectively, for a JIT friendly experience. + +As always, this release is 100% compatible with the previous one and fixed +several issues and bugs raised by the growing community of PyPy users. +We strongly recommend updating. + +The PyPy3.6 release and the Windows PyPy3.5 release are still not production +quality so your mileage may vary. There are open issues with incomplete +compatibility and c-extension support. + +The utf8 branch that changes internal representation of unicode to utf8 did not +make it into the release, so there is still more goodness coming. +You can download the v6.0 releases here: + + http://pypy.org/download.html + +We would like to thank our donors for the continued support of the PyPy +project. If PyPy is not quite good enough for your needs, we are available for +direct consulting work. + +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. + +.. _`PyPy`: index.html +.. _`RPython`: https://rpython.readthedocs.org +.. _`help`: project-ideas.html +.. _`cffi`: http://cffi.readthedocs.io +.. _`cppyy`: https://cppyy.readthedocs.io +.. _`available as wheels`: https://github.com/antocuni/pypy-wheels +.. _`GC blog post`: https://morepypy.blogspot.com/2019/01/pypy-for-low-latency-systems.html + + +What is PyPy? +============= + +PyPy is a very compliant Python interpreter, almost a drop-in replacement for +CPython 2.7, 3.5 and 3.6. 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. + +The PyPy release supports: + + * **x86** machines on most common operating systems + (Linux 32/64 bits, Mac OS X 64 bits, Windows 32 bits, OpenBSD, FreeBSD) + + * big- and little-endian variants of **PPC64** running Linux, + + * **s390x** running Linux + +Unfortunately at the moment of writing our ARM buildbots are out of service, +so for now we are **not** releasing any binary for the ARM architecture. + +.. _`PyPy and CPython 2.7.x`: http://speed.pypy.org +.. _`dynamic languages`: http://rpython.readthedocs.io/en/latest/examples.html + + +Changelog +========= + +If not specified, the changes are shared across versions + +* Support ``__set_name__``, ``__init_subclass__`` (Py3.6) +* Support ``cppyy`` in Py3.5 and Py3.6 +* Use implementation-specific site directories in ``sysconfig`` (Py3.5, Py3.6) +* Adding detection of gcc to ``sysconfig`` (Py3.5, Py3.6) +* Fix multiprocessing regression on newer glibcs +* Make sure 'blocking-ness' of socket is set along with default timeout +* Include ``crypt.h`` for ``crypt()`` on Linux +* Improve and re-organize the contributing_ documentation +* Make the ``__module__`` attribute writable, fixing an incompatibility with + NumPy 1.16 +* Implement ``Py_ReprEnter``, ``Py_ReprLeave(), ``PyMarshal_ReadObjectFromString``, + ``PyMarshal_WriteObjectToString``, ``PyObject_DelItemString``, + ``PyMapping_DelItem``, ``PyMapping_DelItemString``, ``PyEval_GetFrame``, + ``PyOS_InputHook``, ``PyErr_FormatFromCause`` (Py3.6), +* Implement new wordcode instruction encoding (Py3.6) +* Log additional gc-minor and gc-collect-step info in the PYPYLOG +* The ``reverse-debugger`` (revdb) branch has been merged to the default + branch, so it should always be up-to-date. You still need a special pypy + build, but you can compile it from the same source as the one we distribute + for the v7.0.0 release. For more information, see + https://bitbucket.org/pypy/revdb +* Support underscores in numerical literals like ``'4_2'`` (Py3.6) +* Pre-emptively raise MemoryError if the size of dequeue in ``_collections.deque`` + is too large (Py3.5) +* Fix multithreading issues in calls to ``os.setenv`` +* Add missing defines and typedefs for numpy and pandas on MSVC +* Add CPython macros like ``Py_NAN`` to header files +* Rename the ``MethodType`` to ``instancemethod``, like CPython +* Better support for `async with` in generators (Py3.5, Py3.6) +* Improve the performance of ``pow(a, b, c)`` if ``c`` is a large integer +* Now ``vmprof`` works on FreeBSD +* Support GNU Hurd, fixes for FreeBSD +* Add deprecation warning if type of result of ``__float__`` is float inherited + class (Py3.6) +* Fix async generator bug when yielding a ``StopIteration`` (Py3.6) +* Speed up ``max(list-of-int)`` from non-jitted code +* Fix Windows ``os.listdir()`` for some cases (see CPython #32539) +* Add ``select.PIPE_BUF`` +* Use ``subprocess`` to avoid shell injection in ``shutil`` module - backport + of https://bugs.python.org/issue34540 +* Rename ``_Py_ZeroStruct`` to ``_Py_FalseStruct`` (Py3.5, Py3.6) +* Remove some cpyext names for Py3.5, Py3.6 +* Enable use of unicode file names in ``dlopen`` +* Backport CPython fix for ``thread.RLock`` +* Make GC hooks measure time in seconds (as opposed to an opaque unit) +* Refactor and reorganize tests in ``test_lib_pypy`` +* Check error values in ``socket.setblocking`` (Py3.6) +* Add support for FsPath to os.unlink() (Py3.6) +* Fix freezing builtin modules at translation +* Tweak ``W_UnicodeDictionaryStrategy`` which speeds up dictionaries with only + unicode keys + +We also refactored many parts of the JIT bridge optimizations, as well as cpyext +internals, and together with new contributors fixed issues, added new +documentation, and cleaned up the codebase. + +.. _contributing: http://doc.pypy.org/en/latest/contributing.html 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,44 +1,9 @@ ========================== -What's new in PyPy2.7 6.0+ +What's new in PyPy2.7 7.0+ ========================== -.. this is a revision shortly after release-pypy-6.0.0 -.. startrev: e50e11af23f1 - -.. branch: cppyy-packaging - -Main items: vastly better template resolution and improved performance. In -detail: upgrade to backend 1.4, improved handling of templated methods and -functions (in particular automatic deduction of types), improved pythonization -interface, range of compatibility fixes for Python3, free functions now take -fast libffi path when possible, moves for strings (incl. from Python str), -easier/faster handling of std::vector by numpy, improved and faster object -identity preservation - -.. branch: socket_default_timeout_blockingness - -Make sure 'blocking-ness' of socket is set along with default timeout - -.. branch: crypt_h - -Include crypt.h for crypt() on Linux - -.. branch: gc-more-logging - -Log additional gc-minor and gc-collect-step info in the PYPYLOG - -.. branch: reverse-debugger - -The reverse-debugger branch has been merged. For more information, see -https://bitbucket.org/pypy/revdb - -.. branch: pyparser-improvements-3 - -Small refactorings in the Python parser. - -.. branch: fix-readme-typo - -.. branch: avoid_shell_injection_in_shutil +.. this is a revision shortly after release-pypy-7.0.0 +.. startrev: 481c69f7d81f .. branch: unicode-utf8-re @@ -49,32 +14,6 @@ .. branch: pyparser-improvements-3 Small refactorings in the Python parser. -Backport CPython fix for possible shell injection issue in `distutils.spawn`, -https://bugs.python.org/issue34540 - -.. branch: cffi_dlopen_unicode - -Enable use of unicode file names in `dlopen` - -.. branch: rlock-in-rpython - -Backport CPython fix for `thread.RLock` - - -.. branch: expose-gc-time - -Make GC hooks measure time in seconds (as opposed to an opaque unit). - -.. branch: cleanup-test_lib_pypy - -Update most test_lib_pypy/ tests and move them to extra_tests/. - -.. branch: gc-disable - -Make it possible to manually manage the GC by using a combination of -gc.disable() and gc.collect_step(). Make sure to write a proper release -announcement in which we explain that existing programs could leak memory if -they run for too much time between a gc.disable()/gc.enable() .. branch: unicode-utf8 diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-pypy2-7.0.0.rst copy from pypy/doc/whatsnew-head.rst copy to pypy/doc/whatsnew-pypy2-7.0.0.rst diff --git a/pypy/doc/whatsnew-pypy3-head.rst b/pypy/doc/whatsnew-pypy3-7.0.0.rst copy from pypy/doc/whatsnew-pypy3-head.rst copy to pypy/doc/whatsnew-pypy3-7.0.0.rst 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 @@ -1,14 +1,7 @@ -======================== -What's new in PyPy3 6.0+ -======================== - -.. this is the revision after release-pypy3.5-v6.0 -.. startrev: 580e3e26cd32 - -.. branch: unicode-utf8 - -Use utf-8 internally to represent unicode strings - -.. branch: unicode-utf8-py3 - -Use utf-8 internally to represent unicode strings +======================== +What's new in PyPy3 7.0+ +======================== + +.. this is the revision after release-pypy3.5-v7.0 +.. startrev: 9d2fa7c63b7c + 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 @@ -3,7 +3,6 @@ # See test/test_app_main. # Missing vs CPython: -b, -d, -x -from __future__ import print_function, unicode_literals USAGE1 = __doc__ = """\ Options and arguments (and corresponding environment variables): -B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x @@ -334,7 +333,7 @@ del encerr def create_stdio(fd, writing, name, encoding, errors, unbuffered): - import io + import _io # stdin is always opened in buffered mode, first because it # shouldn't make a difference in common use cases, second because # TextIOWrapper depends on the presence of a read1() method which @@ -342,7 +341,7 @@ buffering = 0 if unbuffered and writing else -1 mode = 'w' if writing else 'r' try: - buf = io.open(fd, mode + 'b', buffering, closefd=False) + buf = _io.open(fd, mode + 'b', buffering, closefd=False) except OSError as e: if e.errno != errno.EBADF: raise @@ -352,7 +351,7 @@ raw.name = name # translate \r\n to \n for sys.stdin on Windows newline = None if sys.platform == 'win32' and not writing else '\n' - stream = io.TextIOWrapper(buf, encoding, errors, newline=newline, + stream = _io.TextIOWrapper(buf, encoding, errors, newline=newline, line_buffering=unbuffered or raw.isatty()) stream.mode = mode return stream @@ -549,12 +548,6 @@ return options -# this indirection is needed to be able to import this module on python2, else -# we have a SyntaxError: unqualified exec in a nested function -@hidden_applevel -def exec_(src, dic): - exec(src, dic) - @hidden_applevel def run_command_line(interactive, inspect, @@ -663,7 +656,7 @@ else: if not isolated: sys.path.insert(0, '') - success = run_toplevel(exec_, bytes, mainmodule.__dict__) + success = run_toplevel(exec, bytes, mainmodule.__dict__) elif run_module != 0: # handle the "-m" command # '' on sys.path is required also here @@ -703,7 +696,7 @@ python_startup, 'exec', PyCF_ACCEPT_NULL_BYTES) - exec_(co_python_startup, mainmodule.__dict__) + exec(co_python_startup, mainmodule.__dict__) mainmodule.__file__ = python_startup mainmodule.__cached__ = None run_toplevel(run_it) @@ -721,7 +714,7 @@ def run_it(): co_stdin = compile(sys.stdin.read(), '<stdin>', 'exec', PyCF_ACCEPT_NULL_BYTES) - exec_(co_stdin, mainmodule.__dict__) + exec(co_stdin, mainmodule.__dict__) mainmodule.__file__ = '<stdin>' mainmodule.__cached__ = None success = run_toplevel(run_it) @@ -763,7 +756,7 @@ co = marshal.load(f) if type(co) is not type((lambda:0).__code__): raise RuntimeError("Bad code object in .pyc file") - exec_(co, namespace) + exec(co, namespace) args = (execfile, filename, mainmodule.__dict__) else: filename = sys.argv[0] @@ -791,7 +784,7 @@ code = f.read() co = compile(code, filename, 'exec', PyCF_ACCEPT_NULL_BYTES) - exec_(co, namespace) + exec(co, namespace) args = (execfile, filename, mainmodule.__dict__) success = run_toplevel(*args) 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 @@ -1043,36 +1043,6 @@ assert data.startswith("15\\u20ac ('strict', 'backslashreplace')") -class TestAppMain: - def test_print_info(self): - from pypy.interpreter import app_main - import sys, cStringIO - prev_so = sys.stdout - prev_ti = getattr(sys, 'pypy_translation_info', 'missing') - sys.pypy_translation_info = { - 'translation.foo': True, - 'translation.bar': 42, - 'translation.egg.something': None, - 'objspace.x': 'hello', - } - try: - sys.stdout = f = cStringIO.StringIO() - py.test.raises(SystemExit, app_main.print_info) - finally: - sys.stdout = prev_so - if prev_ti == 'missing': - del sys.pypy_translation_info - else: - sys.pypy_translation_info = prev_ti - assert f.getvalue() == ("[objspace]\n" - " x = 'hello'\n" - "[translation]\n" - " bar = 42\n" - " [egg]\n" - " something = None\n" - " foo = True\n") - - @py.test.mark.skipif('config.getoption("runappdirect")') class AppTestAppMain: def setup_class(self): diff --git a/pypy/module/__builtin__/state.py b/pypy/module/__builtin__/state.py --- a/pypy/module/__builtin__/state.py +++ b/pypy/module/__builtin__/state.py @@ -2,8 +2,8 @@ class State: def __init__(self, space): self.w_open = space.appexec([], """(): - import io - return io.open""") - + import _io + return _io.open""") + def get(space): return space.fromcache(State) diff --git a/pypy/module/_collections/__init__.py b/pypy/module/_collections/__init__.py --- a/pypy/module/_collections/__init__.py +++ b/pypy/module/_collections/__init__.py @@ -8,6 +8,7 @@ appleveldefs = { 'defaultdict': 'app_defaultdict.defaultdict', + 'OrderedDict': 'app_odict.OrderedDict', } interpleveldefs = { @@ -25,15 +26,3 @@ space = self.space space.getattr(self, space.newtext('defaultdict')) # force importing space.delattr(self, space.newtext('__missing__')) - - def startup(self, space): - # OrderedDict is normally present, but in some cases the line - # "from __pypy__ import reversed_dict, move_to_end" from - # _pypy_collections.py raises - space.appexec([self], """(mod): - try: - from _pypy_collections import OrderedDict - mod.OrderedDict = OrderedDict - except ImportError: - pass - """) diff --git a/lib_pypy/_pypy_collections.py b/pypy/module/_collections/app_odict.py rename from lib_pypy/_pypy_collections.py rename to pypy/module/_collections/app_odict.py --- a/lib_pypy/_pypy_collections.py +++ b/pypy/module/_collections/app_odict.py @@ -1,6 +1,5 @@ from __pypy__ import reversed_dict, move_to_end, objects_in_repr from _operator import eq as _eq -import _collections_abc class OrderedDict(dict): @@ -29,7 +28,33 @@ raise TypeError('expected at most 1 arguments, got %d' % len(args)) self.__update(*args, **kwds) - update = __update = _collections_abc.MutableMapping.update + def update(*args, **kwds): + ''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. + If E present and has a .keys() method, does: for k in E: D[k] = E[k] + If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v + In either case, this is followed by: for k, v in F.items(): D[k] = v + ''' + if not args: + raise TypeError("descriptor 'update' of 'OrderedDict' object " + "needs an argument") + self, *args = args + if len(args) > 1: + raise TypeError('update expected at most 1 arguments, got %d' % + len(args)) + if args: + other = args[0] + if hasattr(other, 'items'): + for key, value in other.items(): + self[key] = value + elif hasattr(other, "keys"): + for key in other.keys(): + self[key] = other[key] + else: + for key, value in other: + self[key] = value + for key, value in kwds.items(): + self[key] = value + __update = update def __reversed__(self): return reversed_dict(self) @@ -106,17 +131,20 @@ "D.values() -> an object providing a view on D's values" return _OrderedDictValuesView(self) +dict_keys = type({}.keys()) +dict_values = type({}.values()) +dict_items = type({}.items()) -class _OrderedDictKeysView(_collections_abc.KeysView): +class _OrderedDictKeysView(dict_keys): def __reversed__(self): - yield from reversed_dict(self._mapping) + yield from reversed_dict(self._dict) -class _OrderedDictItemsView(_collections_abc.ItemsView): +class _OrderedDictItemsView(dict_items): def __reversed__(self): - for key in reversed_dict(self._mapping): - yield (key, self._mapping[key]) + for key in reversed_dict(self._dict): + yield (key, self._dict[key]) -class _OrderedDictValuesView(_collections_abc.ValuesView): +class _OrderedDictValuesView(dict_values): def __reversed__(self): - for key in reversed_dict(self._mapping): - yield self._mapping[key] + for key in reversed_dict(self._dict): + yield self._dict[key] diff --git a/pypy/module/_collections/test/test_ordereddict.py b/pypy/module/_collections/test/test_ordereddict.py --- a/pypy/module/_collections/test/test_ordereddict.py +++ b/pypy/module/_collections/test/test_ordereddict.py @@ -22,3 +22,17 @@ assert d['x'] == 42 d.update({'y': 2}) assert d['y'] == 42 + + def test_reversed(self): + import sys + from _collections import OrderedDict + + pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)] + od = OrderedDict(pairs) + if '__pypy__' in sys.builtin_module_names: + # dict ordering is wrong when testing interpreted on top of CPython + pairs = list(dict(od).items()) + assert list(reversed(od)) == [t[0] for t in reversed(pairs)] + assert list(reversed(od.keys())) == [t[0] for t in reversed(pairs)] + assert list(reversed(od.values())) == [t[1] for t in reversed(pairs)] + assert list(reversed(od.items())) == list(reversed(pairs)) diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py --- a/pypy/module/cpyext/api.py +++ b/pypy/module/cpyext/api.py @@ -512,6 +512,7 @@ header = DEFAULT_HEADER if func.__name__ in FUNCTIONS_BY_HEADER[header]: raise ValueError("%s already registered" % func.__name__) + func._revdb_c_only_ = True # hack for revdb api_function = COnlyApiFunction(argtypes, restype, func) FUNCTIONS_BY_HEADER[header][func.__name__] = api_function return api_function diff --git a/pypy/module/cpyext/include/patchlevel.h b/pypy/module/cpyext/include/patchlevel.h --- a/pypy/module/cpyext/include/patchlevel.h +++ b/pypy/module/cpyext/include/patchlevel.h @@ -32,7 +32,7 @@ * module/sys/version.py * doc/conf.py */ -#define PYPY_VERSION "7.1.0" +#define PYPY_VERSION "7.1.0-alpha0" #define PYPY_VERSION_NUM 0x07010000 /* Defined to mean a PyPy where cpyext holds more regular references to PyObjects, e.g. staying alive as long as the internal PyPy object diff --git a/pypy/module/sys/version.py b/pypy/module/sys/version.py --- a/pypy/module/sys/version.py +++ b/pypy/module/sys/version.py @@ -13,7 +13,7 @@ # make sure to keep PYPY_VERSION in sync with: # module/cpyext/include/patchlevel.h # doc/conf.py -PYPY_VERSION = (7, 1, 0, "alpha0", 0) +PYPY_VERSION = (7, 1, 0, "alpha", 0) import pypy diff --git a/pypy/objspace/std/dictmultiobject.py b/pypy/objspace/std/dictmultiobject.py --- a/pypy/objspace/std/dictmultiobject.py +++ b/pypy/objspace/std/dictmultiobject.py @@ -11,7 +11,7 @@ WrappedDefault, applevel, interp2app, unwrap_spec) from pypy.interpreter.mixedmodule import MixedModule from pypy.interpreter.signature import Signature -from pypy.interpreter.typedef import TypeDef +from pypy.interpreter.typedef import TypeDef, interp_attrproperty_w from pypy.interpreter.unicodehelper import decode_utf8sp from pypy.objspace.std.util import negate @@ -1519,6 +1519,12 @@ descr_or, descr_ror = _as_set_op('or', 'update') descr_xor, descr_rxor = _as_set_op('xor', 'symmetric_difference_update') +def new_dict_items(space, w_type, w_dict): + w_dict = space.interp_w(W_DictMultiObject, w_dict) + w_obj = space.allocate_instance(W_DictViewItemsObject, w_type) + W_DictViewObject.__init__(w_obj, space, w_dict) + return w_obj + class W_DictViewItemsObject(W_DictViewObject, SetLikeDictView): def descr_iter(self, space): return W_DictMultiIterItemsObject(space, self.w_dict.iteritems()) @@ -1538,18 +1544,32 @@ return space.w_False return space.newbool(space.eq_w(w_value, w_found)) +def new_dict_keys(space, w_type, w_dict): + w_dict = space.interp_w(W_DictMultiObject, w_dict) + w_obj = space.allocate_instance(W_DictViewKeysObject, w_type) + W_DictViewObject.__init__(w_obj, space, w_dict) + return w_obj + class W_DictViewKeysObject(W_DictViewObject, SetLikeDictView): def descr_iter(self, space): return W_DictMultiIterKeysObject(space, self.w_dict.iterkeys()) + def descr_contains(self, space, w_key): return self.w_dict.descr_contains(space, w_key) +def new_dict_values(space, w_type, w_dict): + w_dict = space.interp_w(W_DictMultiObject, w_dict) + w_obj = space.allocate_instance(W_DictViewValuesObject, w_type) + W_DictViewObject.__init__(w_obj, space, w_dict) + return w_obj + class W_DictViewValuesObject(W_DictViewObject): def descr_iter(self, space): return W_DictMultiIterValuesObject(space, self.w_dict.itervalues()) W_DictViewItemsObject.typedef = TypeDef( "dict_items", + __new__ = interp2app(new_dict_items), __repr__ = interp2app(W_DictViewItemsObject.descr_repr), __len__ = interp2app(W_DictViewItemsObject.descr_len), __iter__ = interp2app(W_DictViewItemsObject.descr_iter), @@ -1571,10 +1591,12 @@ __xor__ = interp2app(W_DictViewItemsObject.descr_xor), __rxor__ = interp2app(W_DictViewItemsObject.descr_rxor), isdisjoint = interp2app(W_DictViewItemsObject.descr_isdisjoint), + _dict = interp_attrproperty_w('w_dict', cls=W_DictViewItemsObject), ) W_DictViewKeysObject.typedef = TypeDef( "dict_keys", + __new__ = interp2app(new_dict_keys), __repr__ = interp2app(W_DictViewKeysObject.descr_repr), __len__ = interp2app(W_DictViewKeysObject.descr_len), __iter__ = interp2app(W_DictViewKeysObject.descr_iter), @@ -1596,11 +1618,14 @@ __xor__ = interp2app(W_DictViewKeysObject.descr_xor), __rxor__ = interp2app(W_DictViewKeysObject.descr_rxor), isdisjoint = interp2app(W_DictViewKeysObject.descr_isdisjoint), + _dict = interp_attrproperty_w('w_dict', cls=W_DictViewKeysObject), ) W_DictViewValuesObject.typedef = TypeDef( "dict_values", + __new__ = interp2app(new_dict_values), __repr__ = interp2app(W_DictViewValuesObject.descr_repr), __len__ = interp2app(W_DictViewValuesObject.descr_len), __iter__ = interp2app(W_DictViewValuesObject.descr_iter), + _dict = interp_attrproperty_w('w_dict', cls=W_DictViewValuesObject), ) diff --git a/pypy/objspace/std/test/test_dictmultiobject.py b/pypy/objspace/std/test/test_dictmultiobject.py --- a/pypy/objspace/std/test/test_dictmultiobject.py +++ b/pypy/objspace/std/test/test_dictmultiobject.py @@ -790,17 +790,6 @@ assert len(d.items()) == 2 assert len(d.values()) == 2 - def test_constructors_not_callable(self): - kt = type({}.keys()) - raises(TypeError, kt, {}) - raises(TypeError, kt) - it = type({}.items()) - raises(TypeError, it, {}) - raises(TypeError, it) - vt = type({}.values()) - raises(TypeError, vt, {}) - raises(TypeError, vt) - def test_dict_keys(self): d = {1: 10, "a": "ABC"} keys = d.keys() diff --git a/rpython/rlib/rgc.py b/rpython/rlib/rgc.py --- a/rpython/rlib/rgc.py +++ b/rpython/rlib/rgc.py @@ -67,7 +67,7 @@ """Returns True if we have a "split GC address space", i.e. if we are translating with an option that doesn't support taking raw addresses inside GC objects and "hacking" at them. This is - notably the case with --reversedb.""" + notably the case with --revdb.""" return False # for test purposes we allow objects to be pinned and use diff --git a/rpython/rlib/src/boehm-rawrefcount.c b/rpython/rlib/src/boehm-rawrefcount.c --- a/rpython/rlib/src/boehm-rawrefcount.c +++ b/rpython/rlib/src/boehm-rawrefcount.c @@ -191,6 +191,7 @@ #endif assert(result->ob_refcnt == REFCNT_FROM_PYPY); result->ob_refcnt = 1; + result->ob_pypy_link = 0; p->pyobj = NULL; *pp = p->next_in_bucket; p->next_in_bucket = hash_free_list; diff --git a/rpython/tool/setuptools_msvc.py b/rpython/tool/setuptools_msvc.py --- a/rpython/tool/setuptools_msvc.py +++ b/rpython/tool/setuptools_msvc.py @@ -27,7 +27,6 @@ import platform import itertools import distutils.errors -from pkg_resources.extern.packaging.version import LegacyVersion from setuptools.extern.six.moves import filterfalse @@ -201,6 +200,7 @@ """ if "numpy.distutils" in sys.modules: import numpy as np + from pkg_resources.extern.packaging.version import LegacyVersion if LegacyVersion(np.__version__) < LegacyVersion('1.11.2'): return np.distutils.ccompiler.gen_lib_options(*args, **kwargs) return get_unpatched(msvc14_gen_lib_options)(*args, **kwargs) diff --git a/rpython/translator/platform/windows.py b/rpython/translator/platform/windows.py --- a/rpython/translator/platform/windows.py +++ b/rpython/translator/platform/windows.py @@ -56,7 +56,12 @@ # use setuptools from python3 to find tools try: vcdict = _find_vcvarsall(vsver, x64flag) + except ImportError as e: + if 'setuptools' in str(e): + log.error('is setuptools installed (perhaps try %s -mensurepip)?' % sys.executable) + log.error('looking for compiler %s raised exception "%s' % (vsver, str(e))) except Exception as e: + log.error('looking for compiler %s raised exception "%s' % (vsver, str(e))) return None else: if x64flag: diff --git a/rpython/translator/revdb/gencsupp.py b/rpython/translator/revdb/gencsupp.py --- a/rpython/translator/revdb/gencsupp.py +++ b/rpython/translator/revdb/gencsupp.py @@ -51,6 +51,10 @@ ## return False def prepare_function(funcgen): + if getattr(getattr(funcgen.graph, 'func', None), '_revdb_c_only_', False): + extra_enter_text = 'RPY_REVDB_C_ONLY_ENTER' + extra_return_text = 'RPY_REVDB_C_ONLY_LEAVE' + return extra_enter_text, extra_return_text stack_bottom = False for block in funcgen.graph.iterblocks(): for op in block.operations: diff --git a/rpython/translator/revdb/src-revdb/revdb.c b/rpython/translator/revdb/src-revdb/revdb.c --- a/rpython/translator/revdb/src-revdb/revdb.c +++ b/rpython/translator/revdb/src-revdb/revdb.c @@ -253,7 +253,10 @@ "(use REVDB=logfile)\n", (int)getpid()); } - rpy_revdb.buf_p = rpy_rev_buffer + sizeof(int16_t); + if (rpy_rev_fileno >= 0) + rpy_revdb.buf_p = rpy_rev_buffer + sizeof(int16_t); + else + rpy_revdb.buf_p = NULL; rpy_revdb.buf_limit = rpy_rev_buffer + sizeof(rpy_rev_buffer) - 32; rpy_revdb.unique_id_seen = 1; @@ -269,17 +272,23 @@ ssize_t full_size; assert(rpy_revdb.lock); + if (rpy_revdb.buf_p == NULL) + return; + assert(rpy_rev_fileno >= 0); + /* write the current buffer content to the OS */ full_size = rpy_revdb.buf_p - rpy_rev_buffer; rpy_revdb.buf_p = rpy_rev_buffer + sizeof(int16_t); - if (rpy_rev_fileno >= 0) - write_all(rpy_rev_buffer, full_size); + write_all(rpy_rev_buffer, full_size); } static ssize_t current_packet_size(void) { /* must be called with the lock held */ - return rpy_revdb.buf_p - (rpy_rev_buffer + sizeof(int16_t)); + if (rpy_revdb.buf_p != NULL) + return rpy_revdb.buf_p - (rpy_rev_buffer + sizeof(int16_t)); + else + return 0; } RPY_EXTERN @@ -327,6 +336,11 @@ rpy_reverse_db_flush(); assert(current_packet_size() == 0); + if (rpy_rev_fileno < 0) + return; + /* should not be here from the middle of a @c_only function */ + assert(rpy_revdb.buf_p != NULL); + *(int16_t *)p = async_code; memcpy(rpy_revdb.buf_p, &content, sizeof(uint64_t)); rpy_revdb.buf_p += sizeof(uint64_t); @@ -472,6 +486,9 @@ if (rpy_rev_fileno < 0) return 1; + /* should not be here from the middle of a @c_only function */ + assert(rpy_revdb.buf_p != NULL); + base_offset = lseek(rpy_rev_fileno, 0, SEEK_CUR); if (base_offset < 0) { perror("lseek"); @@ -488,6 +505,9 @@ if (rpy_rev_fileno < 0) return; + /* should not be here from the middle of a @c_only function */ + assert(rpy_revdb.buf_p != NULL); + base_offset = lseek(rpy_rev_fileno, 0, SEEK_CUR); if (base_offset < 0) { perror("lseek"); @@ -1033,9 +1053,9 @@ " echo 0 | sudo tee /proc/sys/kernel/randomize_va_space\n" "\n" "It has been reported that on Linux kernel 4.12.4-1-ARCH,\n" - "ASLR cannot be disabled at all for libpypy-c.so. For now\n" - "there is no good solution. Either you downgrade the\n" - "kernel, or you translate with --no-shared (and you loose\n" + "ASLR cannot be disabled at all for libpypy-c.so. It works\n" + "again in kernel 4.19 (and maybe sooner). Either change\n" + "kernels, or translate with --no-shared (but then you loose\n" "PyPy's cpyext ability).\n" "\n", argv[0]); exit(1); diff --git a/rpython/translator/revdb/src-revdb/revdb_include.h b/rpython/translator/revdb/src-revdb/revdb_include.h --- a/rpython/translator/revdb/src-revdb/revdb_include.h +++ b/rpython/translator/revdb/src-revdb/revdb_include.h @@ -16,7 +16,8 @@ #endif bool_t watch_enabled; int lock; - char *buf_p, *buf_limit, *buf_readend; + char *buf_p; /* NULL during recording if recording is actually disabled */ + char *buf_limit, *buf_readend; uint64_t stop_point_seen, stop_point_break; uint64_t unique_id_seen, unique_id_break; } rpy_revdb_t; @@ -85,9 +86,13 @@ { \ decl_e = variable; \ _RPY_REVDB_PRINT("[ wr ]", _e); \ - memcpy(rpy_revdb.buf_p, &_e, sizeof(_e)); \ - if ((rpy_revdb.buf_p += sizeof(_e)) > rpy_revdb.buf_limit) \ - rpy_reverse_db_flush(); \ + char *_dst = rpy_revdb.buf_p; \ + if (_dst) { \ + memcpy(_dst, &_e, sizeof(_e)); \ + if ((rpy_revdb.buf_p = _dst + sizeof(_e)) \ + > rpy_revdb.buf_limit) \ + rpy_reverse_db_flush(); \ + } \ } #define _RPY_REVDB_EMIT_REPLAY(decl_e, variable) \ @@ -179,6 +184,13 @@ rpy_reverse_db_bad_acquire_gil("release"); \ } +#define RPY_REVDB_C_ONLY_ENTER \ + char *saved_bufp = rpy_revdb.buf_p; \ + rpy_revdb.buf_p = NULL; + +#define RPY_REVDB_C_ONLY_LEAVE \ + rpy_revdb.buf_p = saved_bufp; + #define RPY_REVDB_CALLBACKLOC(locnum) \ rpy_reverse_db_callback_loc(locnum) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit