Author: Armin Rigo <ar...@tunes.org> Branch: reverse-debugger Changeset: r85122:ea07e83296cd Date: 2016-06-13 11:59 +0200 http://bitbucket.org/pypy/pypy/changeset/ea07e83296cd/
Log: hg merge default diff too long, truncating to 2000 out of 4843 lines diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -25,3 +25,4 @@ 80ef432a32d9baa4b3c5a54c215e8ebe499f6374 release-5.1.2 40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2 40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2 +c09c19272c990a0611b17569a0085ad1ab00c8ff release-pypy2.7-v5.3 diff --git a/LICENSE b/LICENSE --- a/LICENSE +++ b/LICENSE @@ -43,17 +43,17 @@ Samuele Pedroni Matti Picus Alex Gaynor + Philip Jenvey Brian Kearns - Philip Jenvey + Ronan Lamy Michael Hudson - Ronan Lamy + Manuel Jacob David Schneider - Manuel Jacob Holger Krekel Christian Tismer Hakan Ardo + Richard Plangger Benjamin Peterson - Richard Plangger Anders Chrigstrom Eric van Riet Paap Wim Lavrijsen @@ -93,9 +93,9 @@ stian Jan de Mooij Tyler Wade + Vincent Legoll Michael Foord Stephan Diehl - Vincent Legoll Stefan Schwarzer Valentino Volonghi Tomek Meka @@ -104,17 +104,20 @@ Bruno Gola David Malcolm Jean-Paul Calderone + Mark Young Timo Paulssen Squeaky + Devin Jeanpierre Marius Gedminas Alexandre Fayolle Simon Burton + Stefano Rivera Martin Matusiak Konstantin Lopuhin - Stefano Rivera Wenzhu Man John Witulski Laurence Tratt + Raffael Tfirst Ivan Sichmann Freitas Greg Price Dario Bertini @@ -122,13 +125,13 @@ Simon Cross Edd Barrett Andreas Stührk + Tobias Pape Jean-Philippe St. Pierre Guido van Rossum Pavel Vinogradov Spenser Bauman Jeremy Thurgood Paweł Piotr Przeradowski - Tobias Pape Paul deGrandis Ilya Osadchiy marky1991 @@ -140,7 +143,6 @@ Georg Brandl Bert Freudenberg Stian Andreassen - Mark Young Wanja Saatkamp Gerald Klix Mike Blume @@ -156,11 +158,13 @@ Dusty Phillips Lukas Renggli Guenter Jantzen + William Leslie Ned Batchelder Tim Felgentreff Anton Gulenko Amit Regmi Ben Young + Sergey Matyunin Nicolas Chauvat Andrew Durdin Andrew Chambers @@ -171,9 +175,9 @@ Yichao Yu Rocco Moretti Gintautas Miliauskas - Devin Jeanpierre Michael Twomey Lucian Branescu Mihaila + anatoly techtonik Gabriel Lavoie Olivier Dormond Jared Grubb @@ -183,8 +187,6 @@ Brian Dorsey Victor Stinner Andrews Medina - anatoly techtonik - Sergey Matyunin Stuart Williams Jasper Schulz Christian Hudon @@ -208,11 +210,11 @@ Alex Perry Vaibhav Sood Alan McIntyre - William Leslie Alexander Sedov Attila Gobi Jasper.Schulz Christopher Pope + Florin Papa Christian Tismer Marc Abramowitz Dan Stromberg @@ -228,7 +230,6 @@ Lukas Vacek Kunal Grover Andrew Dalke - Florin Papa Sylvain Thenault Jakub Stasiak Nathan Taylor @@ -270,8 +271,9 @@ Yury V. Zaytsev Anna Katrina Dominguez Bobby Impollonia - t...@eistee.fritz.box + Vasantha Ganesh K Andrew Thompson + florinpapa Yusei Tahara Aaron Tubbs Ben Darnell @@ -295,9 +297,9 @@ Akira Li Gustavo Niemeyer Stephan Busemann - florinpapa Rafał Gałczyński Matt Bogosian + timo Christian Muirhead Berker Peksag James Lan 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.6.0 +Version: 1.7.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.6.0" -__version_info__ = (1, 6, 0) +__version__ = "1.7.0" +__version_info__ = (1, 7, 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 @@ -57,6 +57,12 @@ # define _CFFI_UNUSED_FN /* nothing */ #endif +#ifdef __cplusplus +# ifndef _Bool +# define _Bool bool /* semi-hackish: C++ has no _Bool; bool is builtin */ +# endif +#endif + /********** CPython-specific section **********/ #ifndef PYPY_VERSION 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.6.0" + "\ncompiled with cffi version: 1.7.0" "\n_cffi_backend module: ", f); modules = PyImport_GetModuleDict(); mod = PyDict_GetItemString(modules, "_cffi_backend"); diff --git a/lib_pypy/cffi/backend_ctypes.py b/lib_pypy/cffi/backend_ctypes.py --- a/lib_pypy/cffi/backend_ctypes.py +++ b/lib_pypy/cffi/backend_ctypes.py @@ -205,9 +205,7 @@ def __nonzero__(self): return bool(self._address) - - def __bool__(self): - return bool(self._address) + __bool__ = __nonzero__ @classmethod def _to_ctypes(cls, value): @@ -465,6 +463,7 @@ else: def __nonzero__(self): return self._value != 0 + __bool__ = __nonzero__ if kind == 'float': @staticmethod diff --git a/pypy/conftest.py b/pypy/conftest.py --- a/pypy/conftest.py +++ b/pypy/conftest.py @@ -76,6 +76,20 @@ def pytest_pycollect_makemodule(path, parent): return PyPyModule(path, parent) +def is_applevel(item): + from pypy.tool.pytest.apptest import AppTestFunction + return isinstance(item, AppTestFunction) + +def pytest_collection_modifyitems(config, items): + if config.option.runappdirect: + return + for item in items: + if isinstance(item, py.test.Function): + if is_applevel(item): + item.add_marker('applevel') + else: + item.add_marker('interplevel') + class PyPyModule(py.test.collect.Module): """ we take care of collecting classes both at app level and at interp-level (because we need to stick a space @@ -110,9 +124,6 @@ if name.startswith('AppTest'): from pypy.tool.pytest.apptest import AppClassCollector return AppClassCollector(name, parent=self) - else: - from pypy.tool.pytest.inttest import IntClassCollector - return IntClassCollector(name, parent=self) elif hasattr(obj, 'func_code') and self.funcnamefilter(name): if name.startswith('app_test_'): @@ -120,11 +131,7 @@ "generator app level functions? you must be joking" from pypy.tool.pytest.apptest import AppTestFunction return AppTestFunction(name, parent=self) - elif obj.func_code.co_flags & 32: # generator function - return pytest.Generator(name, parent=self) - else: - from pypy.tool.pytest.inttest import IntTestFunction - return IntTestFunction(name, parent=self) + return super(PyPyModule, self).makeitem(name, obj) def skip_on_missing_buildoption(**ropts): __tracebackhide__ = True @@ -153,35 +160,19 @@ def pytest_runtest_setup(__multicall__, item): if isinstance(item, py.test.collect.Function): - appclass = item.getparent(PyPyClassCollector) + appclass = item.getparent(py.test.Class) if appclass is not None: # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', None) if spaceconfig is not None: from pypy.tool.pytest.objspace import gettestobjspace appclass.obj.space = gettestobjspace(**spaceconfig) + else: + appclass.obj.space = LazyObjSpaceGetter() appclass.obj.runappdirect = option.runappdirect __multicall__.execute() -def pytest_runtest_teardown(__multicall__, item): - __multicall__.execute() - - if 'pygame' in sys.modules: - assert option.view, ("should not invoke Pygame " - "if conftest.option.view is False") - - -class PyPyClassCollector(py.test.collect.Class): - # All pypy Test classes have a "space" member. - def setup(self): - cls = self.obj - if not hasattr(cls, 'spaceconfig'): - cls.space = LazyObjSpaceGetter() - else: - assert hasattr(cls, 'space') # set by pytest_runtest_setup - super(PyPyClassCollector, self).setup() - def pytest_ignore_collect(path): return path.check(link=1) diff --git a/pypy/doc/contributor.rst b/pypy/doc/contributor.rst --- a/pypy/doc/contributor.rst +++ b/pypy/doc/contributor.rst @@ -13,17 +13,17 @@ Samuele Pedroni Matti Picus Alex Gaynor + Philip Jenvey Brian Kearns - Philip Jenvey + Ronan Lamy Michael Hudson - Ronan Lamy + Manuel Jacob David Schneider - Manuel Jacob Holger Krekel Christian Tismer Hakan Ardo + Richard Plangger Benjamin Peterson - Richard Plangger Anders Chrigstrom Eric van Riet Paap Wim Lavrijsen @@ -63,9 +63,9 @@ stian Jan de Mooij Tyler Wade + Vincent Legoll Michael Foord Stephan Diehl - Vincent Legoll Stefan Schwarzer Valentino Volonghi Tomek Meka @@ -74,31 +74,34 @@ Bruno Gola David Malcolm Jean-Paul Calderone + Mark Young Timo Paulssen Squeaky + Devin Jeanpierre Marius Gedminas Alexandre Fayolle Simon Burton + Stefano Rivera Martin Matusiak Konstantin Lopuhin - Stefano Rivera Wenzhu Man John Witulski Laurence Tratt + Raffael Tfirst Ivan Sichmann Freitas Greg Price Dario Bertini Mark Pearse Simon Cross + Edd Barrett Andreas Stührk - Edd Barrett + Tobias Pape Jean-Philippe St. Pierre Guido van Rossum Pavel Vinogradov Spenser Bauman Jeremy Thurgood Paweł Piotr Przeradowski - Tobias Pape Paul deGrandis Ilya Osadchiy marky1991 @@ -110,7 +113,6 @@ Georg Brandl Bert Freudenberg Stian Andreassen - Mark Young Wanja Saatkamp Gerald Klix Mike Blume @@ -126,11 +128,13 @@ Dusty Phillips Lukas Renggli Guenter Jantzen + William Leslie Ned Batchelder Tim Felgentreff Anton Gulenko Amit Regmi Ben Young + Sergey Matyunin Nicolas Chauvat Andrew Durdin Andrew Chambers @@ -141,9 +145,9 @@ Yichao Yu Rocco Moretti Gintautas Miliauskas - Devin Jeanpierre Michael Twomey Lucian Branescu Mihaila + anatoly techtonik Gabriel Lavoie Olivier Dormond Jared Grubb @@ -153,8 +157,6 @@ Brian Dorsey Victor Stinner Andrews Medina - anatoly techtonik - Sergey Matyunin Stuart Williams Jasper Schulz Christian Hudon @@ -178,11 +180,11 @@ Alex Perry Vaibhav Sood Alan McIntyre - William Leslie Alexander Sedov Attila Gobi Jasper.Schulz Christopher Pope + Florin Papa Christian Tismer Marc Abramowitz Dan Stromberg @@ -198,7 +200,6 @@ Lukas Vacek Kunal Grover Andrew Dalke - Florin Papa Sylvain Thenault Jakub Stasiak Nathan Taylor @@ -240,8 +241,9 @@ Yury V. Zaytsev Anna Katrina Dominguez Bobby Impollonia - t...@eistee.fritz.box + Vasantha Ganesh K Andrew Thompson + florinpapa Yusei Tahara Aaron Tubbs Ben Darnell @@ -265,9 +267,9 @@ Akira Li Gustavo Niemeyer Stephan Busemann - florinpapa Rafał Gałczyński Matt Bogosian + timo Christian Muirhead Berker Peksag James Lan 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.3.0.rst release-5.1.1.rst release-5.1.0.rst release-5.0.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.3.0.rst whatsnew-5.1.0.rst whatsnew-5.0.0.rst whatsnew-4.0.1.rst diff --git a/pypy/doc/project-ideas.rst b/pypy/doc/project-ideas.rst --- a/pypy/doc/project-ideas.rst +++ b/pypy/doc/project-ideas.rst @@ -53,15 +53,17 @@ immediately, but only when (and if) ``myslice`` or ``mylist`` are mutated. -Numpy improvements ------------------- +NumPy rebooted +-------------- -The numpy is rapidly progressing in pypy, so feel free to come to IRC and -ask for proposed topic. A not necesarilly up-to-date `list of topics`_ -is also available. +Our cpyext C-API compatiblity layer can now run upstream NumPy unmodified. +Release PyPy2.7-v5.3 still fails about 200 of the ~6000 test in the NumPy +test suite. We could use help analyzing the failures and fixing them either +as patches to upstream NumPy, or as fixes to PyPy. -.. _list of topics: https://bitbucket.org/pypy/extradoc/src/extradoc/planning/micronumpy.txt - +We also are looking for help in how to hijack NumPy dtype conversion and +ufunc calls to allow the JIT to make them fast, using our internal _numpypy +module. Improving the jitviewer ------------------------ diff --git a/pypy/doc/release-pypy2.7-v5.3.0.rst b/pypy/doc/release-pypy2.7-v5.3.0.rst --- a/pypy/doc/release-pypy2.7-v5.3.0.rst +++ b/pypy/doc/release-pypy2.7-v5.3.0.rst @@ -2,15 +2,18 @@ PyPy2.7 v5.3 ============ -We have released PyPy2.7 v5.3, about six weeks after PyPy 5.1. -This release includes further improvements for the CAPI compatibility layer -which we call cpyext. In addtion to complete support for lxml, we now pass -most (more than 90%) of the upstream numpy test suite, and much of SciPy is -supported as well. +We have released PyPy2.7 v5.3, about six weeks after PyPy 5.1 and a week after +`PyPy3.3 v5.2 alpha 1`_, the first PyPy release targetting 3.3 +compatibility. This new PyPy2.7 release includes further improvements for the +CAPI compatibility layer which we call cpyext. In addtion to complete support +for lxml, we now pass most (more than 90%) of the upstream numpy test suite, +and much of SciPy is supported as well. -We also improved the speed of ... and ... +We updated cffi_ to version 1.7 (small changes, documented here_). -We updated cffi_ to ... +.. _`PyPy3.3 v5.2 alpha 1`: http://morepypy.blogspot.com/2016/05/pypy33-v52-alpha-1-released.html +.. _cffi: https://cffi.readthedocs.org +.. _here: http://cffi.readthedocs.io/en/latest/whatsnew.html You can download the PyPy2.7 v5.3 release here: @@ -29,10 +32,6 @@ .. _`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 -.. _`numpy`: https://bitbucket.org/pypy/numpy -.. _cffi: https://cffi.readthedocs.org -.. _`fully support for the IBM s390x`: http://morepypy.blogspot.com/2016/04/pypy-enterprise-edition.html -.. _`blog post`: http://morepypy.blogspot.com/2016/04/warmup-improvements-more-efficient.html What is PyPy? ============= @@ -41,13 +40,13 @@ 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. +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, Mac OS X 64, Windows 32, OpenBSD, FreeBSD), + (Linux 32/64 bits, Mac OS X 64 bits, Windows 32 bits, OpenBSD, FreeBSD) * newer **ARM** hardware (ARMv6 or ARMv7, with VFPv3) running Linux, @@ -65,6 +64,7 @@ * Merge a major expansion of the C-API support in cpyext, here are some of the highlights: + - allow c-snippet tests to be run with -A so we can verify we are compatible - fix many edge cases exposed by fixing tests to run with -A - issequence() logic matches cpython @@ -72,7 +72,7 @@ - add prelminary support for PyDateTime_* - support PyComplexObject, PyFloatObject, PyDict_Merge, PyDictProxy, PyMemoryView_*, _Py_HashDouble, PyFile_AsFile, PyFile_FromFile, - - PyAnySet_CheckExact, PyUnicode_Concat + PyAnySet_CheckExact, PyUnicode_Concat, PyDateTime_TZInfo - improve support for PyGILState_Ensure, PyGILState_Release, and thread primitives, also find a case where CPython will allow thread creation before PyEval_InitThreads is run, dissallow on PyPy @@ -80,6 +80,10 @@ - rewrite slot assignment for typeobjects - improve tracking of PyObject to rpython object mapping - support tp_as_{number, sequence, mapping, buffer} slots + - support ByteArrayObject via the new resizable_list_supporting_raw_ptr + - implement PyList_SET_ITEM with CPython's behavior, instead of SetItem's + - fix the signature of PyUFunc_FromFuncAndDataAndSignature + - implement many PyWhatever_FOO() as a macro taking a `void *` * CPyExt tweak: instead of "GIL not held when a CPython C extension module calls PyXxx", we now silently acquire/release the GIL. Helps with @@ -93,8 +97,42 @@ * Generalize cpyext old-style buffers to more than just str/buffer, add support for mmap + * Support command line -v to trace import statements + + * Add rposix functions for PyPy3.3 support + + * Give super an __init__ and a simple __new__ for CPython compatibility + + * Revive traceviewer, a tool to use pygame to view traces + * Bug Fixes + * Fix issue #2277: only special-case two exact lists in zip(), not list + subclasses, because an overridden __iter__() should be called (probably) + + * Fix issue #2226: Another tweak in the incremental GC- this should ensure + that progress in the major GC occurs quickly enough in all cases. + + * Clarify and refactor documentation on http://doc.pypy.org + + * Use "must be unicode, not %T" in unicodedata TypeErrors. + + * Manually reset sys.settrace() and sys.setprofile() when we're done running. + This is not exactly what CPython does, but if we get an exception, unlike + CPython, we call functions from the 'traceback' module, and these would + call more the trace/profile function. That's unexpected and can lead + to more crashes at this point. + + * Use the appropriate tp_dealloc on a subclass of a builtin type, and call + tp_new for a python-sublcass of a C-API type + + * Fix for issue #2285 - rare vmprof segfaults on OS/X + + * Fixed issue #2172 - where a test specified an invalid parameter to mmap on powerpc + + * Fix issue #2311 - grab the `__future__` flags imported in the main script, in + `-c`, or in `PYTHON_STARTUP`, and expose them to the `-i` console + * Issues reported with our previous release were resolved_ after reports from users on our issue tracker at https://bitbucket.org/pypy/pypy/issues or on IRC at #pypy @@ -103,6 +141,9 @@ * Implement ufunc.outer on numpypy + * Move PyPy-specific numpy headers to a subdirectory (also changed `the repo`_ + accordingly) + * Performance improvements: * Use bitstrings to compress lists of descriptors that are attached to an @@ -114,11 +155,20 @@ can now be turned into ``x >> 1`` or ``x & 1``, even if x is possibly negative. + * Copy CPython's 'optimization': ignore __iter__ etc. for `f(**dict_subclass())` + + * Use the __builtin_add_overflow built-ins if they are available + + * Rework the way registers are moved/spilled in before_call() * Internal refactorings: + * Refactor code to better support Python3-compatible syntax + + * Document and refactor OperationError -> oefmt + * Reduce the size of generated C sources during translation by - refactoring function declarations + eliminating many many unused struct declarations (Issue #2281) * Remove a number of translation-time options that were not tested and never used. Also fix a performance bug in the method cache @@ -126,10 +176,14 @@ * Reduce the size of generated code by using the same function objects in all generated subclasses + * Share cpyext Py* function wrappers according to the signature, shrinking the + translated libpypy.so by about 10% (measured without the JIT) + * Compile c snippets with -Werror, and fix warnings it exposed .. _resolved: http://doc.pypy.org/en/latest/whatsnew-5.3.0.html .. _Numpy: https://bitbucket.org/pypy/numpy +.. _`the repo`: https://bitbucket.org/pypy/numpy Please update, and continue to help us make PyPy better. 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 @@ -73,6 +73,8 @@ 'Richard Lancaster':['richardlancaster'], 'William Leslie':['William ML Leslie'], 'Spenser Bauman':['Spenser Andrew Bauman'], + 'Raffael Tfirst':['raffael.tfi...@gmail.com'], + 'timo':['t...@eistee.fritz.box'], } 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,145 +1,33 @@ ========================= -What's new in PyPy 5.1+ +What's new in PyPy2.7 5.3+ ========================= -.. this is a revision shortly after release-5.1 -.. startrev: aa60332382a1 +.. this is a revision shortly after release-pypy2.7-v5.3 +.. startrev: 873218a739f1 -.. branch: techtonik/introductionrst-simplify-explanation-abo-1460879168046 +.. pull request #455 +Add sys.{get,set}dlopenflags, for cpyext extensions. -.. branch: gcheader-decl +.. branch: fix-gen-dfa -Reduce the size of generated C sources. +Resolves an issue with the generator script to build the dfa for Python syntax. +.. branch: z196-support -.. branch: remove-objspace-options +Fixes a critical issue in the register allocator and extends support on s390x. +PyPy runs and translates on the s390x revisions z10 (released February 2008, experimental) +and z196 (released August 2010) in addition to zEC12 and z13. +To target e.g. z196 on a zEC12 machine supply CFLAGS="-march=z196" to your shell environment. -Remove a number of options from the build process that were never tested and -never set. Fix a performance bug in the method cache. +.. branch: s390x-5.3-catchup -.. branch: bitstring +Implement the backend related changes for s390x. -JIT: use bitstrings to compress the lists of read or written descrs -that we attach to EffectInfo. Fixes a problem we had in -remove-objspace-options. +.. branch: incminimark-ll_assert +.. branch: vmprof-openbsd -.. branch: cpyext-for-merge +.. branch: testing-cleanup -Update cpyext C-API support After this branch, we are almost able to support -upstream numpy via cpyext, so we created (yet another) fork of numpy at -github.com/pypy/numpy with the needed changes. Among the significant changes -to cpyext: - - allow c-snippet tests to be run with -A so we can verify we are compatible - - fix many edge cases exposed by fixing tests to run with -A - - issequence() logic matches cpython - - make PyStringObject and PyUnicodeObject field names compatible with cpython - - add prelminary support for PyDateTime_* - - support PyComplexObject, PyFloatObject, PyDict_Merge, PyDictProxy, - PyMemoryView_*, _Py_HashDouble, PyFile_AsFile, PyFile_FromFile, - - PyAnySet_CheckExact, PyUnicode_Concat - - improve support for PyGILState_Ensure, PyGILState_Release, and thread - primitives, also find a case where CPython will allow thread creation - before PyEval_InitThreads is run, dissallow on PyPy - - create a PyObject-specific list strategy - - rewrite slot assignment for typeobjects - - improve tracking of PyObject to rpython object mapping - - support tp_as_{number, sequence, mapping, buffer} slots +Simplify handling of interp-level tests and make it more forward- +compatible. -(makes the pypy-c bigger; this was fixed subsequently by the -share-cpyext-cpython-api branch) - -.. branch: share-mapdict-methods-2 - -Reduce generated code for subclasses by using the same function objects in all -generated subclasses. - -.. branch: share-cpyext-cpython-api - -.. branch: cpyext-auto-gil - -CPyExt tweak: instead of "GIL not held when a CPython C extension module -calls PyXxx", we now silently acquire/release the GIL. Helps with -CPython C extension modules that call some PyXxx() functions without -holding the GIL (arguably, they are theorically buggy). - -.. branch: cpyext-test-A - -Get the cpyext tests to pass with "-A" (i.e. when tested directly with -CPython). - -.. branch: oefmt - -.. branch: cpyext-werror - -Compile c snippets with -Werror in cpyext - -.. branch: gc-del-3 - -Add rgc.FinalizerQueue, documented in pypy/doc/discussion/finalizer-order.rst. -It is a more flexible way to make RPython finalizers. - -.. branch: unpacking-cpython-shortcut - -.. branch: cleanups - -.. branch: cpyext-more-slots - -.. branch: use-gc-del-3 - -Use the new rgc.FinalizerQueue mechanism to clean up the handling of -``__del__`` methods. Fixes notably issue #2287. (All RPython -subclasses of W_Root need to use FinalizerQueue now.) - -.. branch: ufunc-outer - -Implement ufunc.outer on numpypy - -.. branch: verbose-imports - -Support ``pypy -v``: verbose imports. It does not log as much as -cpython, but it should be enough to help when debugging package layout -problems. - -.. branch: cpyext-macros-cast - -Fix some warnings when compiling CPython C extension modules - -.. branch: syntax_fix - -.. branch: remove-raisingops - -Remove most of the _ovf, _zer and _val operations from RPython. Kills -quite some code internally, and allows the JIT to do better -optimizations: for example, app-level code like ``x / 2`` or ``x % 2`` -can now be turned into ``x >> 1`` or ``x & 1``, even if x is possibly -negative. - -.. branch: cpyext-old-buffers - -Generalize cpyext old-style buffers to more than just str/buffer, add support for mmap - -.. branch: numpy-includes - -Move _numpypy headers into a directory so they are not picked up by upstream numpy, scipy -This allows building upstream numpy and scipy in pypy via cpyext - -.. branch: traceviewer-common-merge-point-formats - -Teach RPython JIT's off-line traceviewer the most common ``debug_merge_point`` formats. - -.. branch: cpyext-pickle - -Enable pickling of W_PyCFunctionObject by monkeypatching pickle.Pickler.dispatch -at cpyext import time - -.. branch: nonmovable-list - -Add a way to ask "give me a raw pointer to this list's -items". Only for resizable lists of primitives. Turns the GcArray -nonmovable, possibly making a copy of it first. - -.. branch: cpyext-ext - -Finish the work already partially merged in cpyext-for-merge. Adds support -for ByteArrayObject using the nonmovable-list, which also enables -buffer(bytearray(<some-list>)) diff --git a/pypy/doc/whatsnew-pypy2-5.3.0.rst b/pypy/doc/whatsnew-pypy2-5.3.0.rst new file mode 100644 --- /dev/null +++ b/pypy/doc/whatsnew-pypy2-5.3.0.rst @@ -0,0 +1,145 @@ +========================= +What's new in PyPy2.7 5.3 +========================= + +.. this is a revision shortly after release-5.1 +.. startrev: aa60332382a1 + +.. branch: techtonik/introductionrst-simplify-explanation-abo-1460879168046 + +.. branch: gcheader-decl + +Reduce the size of generated C sources. + + +.. branch: remove-objspace-options + +Remove a number of options from the build process that were never tested and +never set. Fix a performance bug in the method cache. + +.. branch: bitstring + +JIT: use bitstrings to compress the lists of read or written descrs +that we attach to EffectInfo. Fixes a problem we had in +remove-objspace-options. + +.. branch: cpyext-for-merge + +Update cpyext C-API support After this branch, we are almost able to support +upstream numpy via cpyext, so we created (yet another) fork of numpy at +github.com/pypy/numpy with the needed changes. Among the significant changes +to cpyext: + - allow c-snippet tests to be run with -A so we can verify we are compatible + - fix many edge cases exposed by fixing tests to run with -A + - issequence() logic matches cpython + - make PyStringObject and PyUnicodeObject field names compatible with cpython + - add prelminary support for PyDateTime_* + - support PyComplexObject, PyFloatObject, PyDict_Merge, PyDictProxy, + PyMemoryView_*, _Py_HashDouble, PyFile_AsFile, PyFile_FromFile, + - PyAnySet_CheckExact, PyUnicode_Concat + - improve support for PyGILState_Ensure, PyGILState_Release, and thread + primitives, also find a case where CPython will allow thread creation + before PyEval_InitThreads is run, dissallow on PyPy + - create a PyObject-specific list strategy + - rewrite slot assignment for typeobjects + - improve tracking of PyObject to rpython object mapping + - support tp_as_{number, sequence, mapping, buffer} slots + +(makes the pypy-c bigger; this was fixed subsequently by the +share-cpyext-cpython-api branch) + +.. branch: share-mapdict-methods-2 + +Reduce generated code for subclasses by using the same function objects in all +generated subclasses. + +.. branch: share-cpyext-cpython-api + +.. branch: cpyext-auto-gil + +CPyExt tweak: instead of "GIL not held when a CPython C extension module +calls PyXxx", we now silently acquire/release the GIL. Helps with +CPython C extension modules that call some PyXxx() functions without +holding the GIL (arguably, they are theorically buggy). + +.. branch: cpyext-test-A + +Get the cpyext tests to pass with "-A" (i.e. when tested directly with +CPython). + +.. branch: oefmt + +.. branch: cpyext-werror + +Compile c snippets with -Werror in cpyext + +.. branch: gc-del-3 + +Add rgc.FinalizerQueue, documented in pypy/doc/discussion/finalizer-order.rst. +It is a more flexible way to make RPython finalizers. + +.. branch: unpacking-cpython-shortcut + +.. branch: cleanups + +.. branch: cpyext-more-slots + +.. branch: use-gc-del-3 + +Use the new rgc.FinalizerQueue mechanism to clean up the handling of +``__del__`` methods. Fixes notably issue #2287. (All RPython +subclasses of W_Root need to use FinalizerQueue now.) + +.. branch: ufunc-outer + +Implement ufunc.outer on numpypy + +.. branch: verbose-imports + +Support ``pypy -v``: verbose imports. It does not log as much as +cpython, but it should be enough to help when debugging package layout +problems. + +.. branch: cpyext-macros-cast + +Fix some warnings when compiling CPython C extension modules + +.. branch: syntax_fix + +.. branch: remove-raisingops + +Remove most of the _ovf, _zer and _val operations from RPython. Kills +quite some code internally, and allows the JIT to do better +optimizations: for example, app-level code like ``x / 2`` or ``x % 2`` +can now be turned into ``x >> 1`` or ``x & 1``, even if x is possibly +negative. + +.. branch: cpyext-old-buffers + +Generalize cpyext old-style buffers to more than just str/buffer, add support for mmap + +.. branch: numpy-includes + +Move _numpypy headers into a directory so they are not picked up by upstream numpy, scipy +This allows building upstream numpy and scipy in pypy via cpyext + +.. branch: traceviewer-common-merge-point-formats + +Teach RPython JIT's off-line traceviewer the most common ``debug_merge_point`` formats. + +.. branch: cpyext-pickle + +Enable pickling of W_PyCFunctionObject by monkeypatching pickle.Pickler.dispatch +at cpyext import time + +.. branch: nonmovable-list + +Add a way to ask "give me a raw pointer to this list's +items". Only for resizable lists of primitives. Turns the GcArray +nonmovable, possibly making a copy of it first. + +.. branch: cpyext-ext + +Finish the work already partially merged in cpyext-for-merge. Adds support +for ByteArrayObject using the nonmovable-list, which also enables +buffer(bytearray(<some-list>)) diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py --- a/pypy/interpreter/astcompiler/test/test_compiler.py +++ b/pypy/interpreter/astcompiler/test/test_compiler.py @@ -458,14 +458,17 @@ decl = str(decl) + "\n" yield self.st, decl, 'x', (1, 2, 3, 4) + def test_closure_error(self): source = """if 1: def f(a): del a def x(): a """ - exc = py.test.raises(SyntaxError, self.run, source).value - assert exc.msg == "Can't delete variable used in nested scopes: 'a'" + with py.test.raises(SyntaxError) as excinfo: + self.run(source) + msg = excinfo.value.msg + assert msg == "Can't delete variable used in nested scopes: 'a'" def test_try_except_finally(self): yield self.simple_test, """ @@ -879,7 +882,20 @@ """ self.simple_test(source, 'ok', 1) - def test_remove_docstring(self): + @py.test.mark.parametrize('expr, result', [ + ("f1.__doc__", None), + ("f2.__doc__", 'docstring'), + ("f2()", 'docstring'), + ("f3.__doc__", None), + ("f3()", 'bar'), + ("C1.__doc__", None), + ("C2.__doc__", 'docstring'), + ("C3.field", 'not docstring'), + ("C4.field", 'docstring'), + ("C4.__doc__", 'docstring'), + ("C4.__doc__", 'docstring'), + ("__doc__", None),]) + def test_remove_docstring(self, expr, result): source = '"module_docstring"\n' + """if 1: def f1(): 'docstring' @@ -903,19 +919,7 @@ code_w.remove_docstrings(self.space) dict_w = self.space.newdict(); code_w.exec_code(self.space, dict_w, dict_w) - - yield self.check, dict_w, "f1.__doc__", None - yield self.check, dict_w, "f2.__doc__", 'docstring' - yield self.check, dict_w, "f2()", 'docstring' - yield self.check, dict_w, "f3.__doc__", None - yield self.check, dict_w, "f3()", 'bar' - yield self.check, dict_w, "C1.__doc__", None - yield self.check, dict_w, "C2.__doc__", 'docstring' - yield self.check, dict_w, "C3.field", 'not docstring' - yield self.check, dict_w, "C4.field", 'docstring' - yield self.check, dict_w, "C4.__doc__", 'docstring' - yield self.check, dict_w, "C4.__doc__", 'docstring' - yield self.check, dict_w, "__doc__", None + self.check(dict_w, expr, result) def test_assert_skipping(self): space = self.space @@ -1111,7 +1115,7 @@ return d['f'](5) """) assert 'generator' in space.str_w(space.repr(w_generator)) - + def test_list_comprehension(self): source = "def f(): [i for i in l]" source2 = "def f(): [i for i in l for j in l]" diff --git a/pypy/interpreter/pyparser/genpytokenize.py b/pypy/interpreter/pyparser/genpytokenize.py --- a/pypy/interpreter/pyparser/genpytokenize.py +++ b/pypy/interpreter/pyparser/genpytokenize.py @@ -191,7 +191,7 @@ newArcPair(states, EMPTY), pseudoExtras, number, funny, contStr, name)) dfaStates, dfaAccepts = nfaToDfa(states, *pseudoToken) - return DFA(dfaStates, dfaAccepts) + return DFA(dfaStates, dfaAccepts), dfaStates # ______________________________________________________________________ @@ -205,7 +205,9 @@ newArcPair(states, DEFAULT), any(states, notGroupStr(states, "'\\")))), newArcPair(states, "'")) - singleDFA = DFA(*nfaToDfa(states, *single)) + states, accepts = nfaToDfa(states, *single) + singleDFA = DFA(states, accepts) + states_singleDFA = states states = [] double = chain(states, any(states, notGroupStr(states, '"\\')), @@ -215,7 +217,9 @@ newArcPair(states, DEFAULT), any(states, notGroupStr(states, '"\\')))), newArcPair(states, '"')) - doubleDFA = DFA(*nfaToDfa(states, *double)) + states, accepts = nfaToDfa(states, *double) + doubleDFA = DFA(states, accepts) + states_doubleDFA = states states = [] single3 = chain(states, any(states, notGroupStr(states, "'\\")), @@ -230,7 +234,9 @@ notChainStr(states, "''"))), any(states, notGroupStr(states, "'\\")))), chainStr(states, "'''")) - single3DFA = NonGreedyDFA(*nfaToDfa(states, *single3)) + states, accepts = nfaToDfa(states, *single3) + single3DFA = NonGreedyDFA(states, accepts) + states_single3DFA = states states = [] double3 = chain(states, any(states, notGroupStr(states, '"\\')), @@ -245,9 +251,11 @@ notChainStr(states, '""'))), any(states, notGroupStr(states, '"\\')))), chainStr(states, '"""')) - double3DFA = NonGreedyDFA(*nfaToDfa(states, *double3)) - map = {"'" : singleDFA, - '"' : doubleDFA, + states, accepts = nfaToDfa(states, *double3) + double3DFA = NonGreedyDFA(states, accepts) + states_double3DFA = states + map = {"'" : (singleDFA, states_singleDFA), + '"' : (doubleDFA, states_doubleDFA), "r" : None, "R" : None, "u" : None, @@ -257,25 +265,30 @@ for uniPrefix in ("", "u", "U", "b", "B", ): for rawPrefix in ("", "r", "R"): prefix = uniPrefix + rawPrefix - map[prefix + "'''"] = single3DFA - map[prefix + '"""'] = double3DFA + map[prefix + "'''"] = (single3DFA, states_single3DFA) + map[prefix + '"""'] = (double3DFA, states_double3DFA) return map # ______________________________________________________________________ -def output(name, dfa_class, dfa): +def output(name, dfa_class, dfa, states): import textwrap + lines = [] i = 0 for line in textwrap.wrap(repr(dfa.accepts), width = 50): if i == 0: - print "accepts =", line + lines.append("accepts = ") else: - print " ", line + lines.append(" ") + lines.append(line) + lines.append("\n") i += 1 import StringIO - print "states = [" - for numstate, state in enumerate(dfa.states): - print " #", numstate + lines.append("states = [\n") + for numstate, state in enumerate(states): + lines.append(" # ") + lines.append(str(numstate)) + lines.append('\n') s = StringIO.StringIO() i = 0 for k, v in sorted(state.items()): @@ -298,22 +311,28 @@ for line in text: line = line.replace('::', ': ') if i == 0: - print ' {' + line + lines.append(' {') else: - print ' ' + line + lines.append(' ') + lines.append(line) + lines.append('\n') i += 1 - print " ]" - print "%s = automata.%s(states, accepts)" % (name, dfa_class) - print + lines.append(" ]\n") + lines.append("%s = automata.%s(states, accepts)\n" % (name, dfa_class)) + return ''.join(lines) def main (): - pseudoDFA = makePyPseudoDFA() - output("pseudoDFA", "DFA", pseudoDFA) + pseudoDFA, states_pseudoDFA = makePyPseudoDFA() + print output("pseudoDFA", "DFA", pseudoDFA, states_pseudoDFA) endDFAMap = makePyEndDFAMap() - output("double3DFA", "NonGreedyDFA", endDFAMap['"""']) - output("single3DFA", "NonGreedyDFA", endDFAMap["'''"]) - output("singleDFA", "DFA", endDFAMap["'"]) - output("doubleDFA", "DFA", endDFAMap['"']) + dfa, states = endDFAMap['"""'] + print output("double3DFA", "NonGreedyDFA", dfa, states) + dfa, states = endDFAMap["'''"] + print output("single3DFA", "NonGreedyDFA", dfa, states) + dfa, states = endDFAMap["'"] + print output("singleDFA", "DFA", dfa, states) + dfa, states = endDFAMap["\""] + print output("doubleDFA", "DFA", dfa, states) # ______________________________________________________________________ diff --git a/pypy/interpreter/pyparser/test/test_gendfa.py b/pypy/interpreter/pyparser/test/test_gendfa.py new file mode 100644 --- /dev/null +++ b/pypy/interpreter/pyparser/test/test_gendfa.py @@ -0,0 +1,16 @@ +from pypy.interpreter.pyparser.automata import DFA, DEFAULT +from pypy.interpreter.pyparser.genpytokenize import output + +def test_states(): + states = [{"\x00": 1}, {"\x01": 0}] + d = DFA(states[:], [False, True]) + assert output('test', DFA, d, states) == """\ +accepts = [False, True] +states = [ + # 0 + {'\\x00': 1}, + # 1 + {'\\x01': 0}, + ] +test = automata.pypy.interpreter.pyparser.automata.DFA(states, accepts) +""" diff --git a/pypy/interpreter/test/test_pyframe.py b/pypy/interpreter/test/test_pyframe.py --- a/pypy/interpreter/test/test_pyframe.py +++ b/pypy/interpreter/test/test_pyframe.py @@ -48,10 +48,10 @@ return f.f_code assert g() is g.func_code - def test_f_trace_del(self): + def test_f_trace_del(self): import sys - f = sys._getframe() - del f.f_trace + f = sys._getframe() + del f.f_trace assert f.f_trace is None def test_f_lineno(self): @@ -116,7 +116,7 @@ def f(): assert sys._getframe().f_code.co_name == g() def g(): - return sys._getframe().f_back.f_code.co_name + return sys._getframe().f_back.f_code.co_name f() def test_f_back_virtualref(self): @@ -233,7 +233,7 @@ def test_trace_exc(self): import sys l = [] - def ltrace(a,b,c): + def ltrace(a,b,c): if b == 'exception': l.append(c) return ltrace @@ -298,7 +298,7 @@ def test_trace_return_exc(self): import sys l = [] - def trace(a,b,c): + def trace(a,b,c): if b in ('exception', 'return'): l.append((b, c)) return trace @@ -444,7 +444,7 @@ def test_dont_trace_on_reraise(self): import sys l = [] - def ltrace(a,b,c): + def ltrace(a,b,c): if b == 'exception': l.append(c) return ltrace @@ -466,7 +466,7 @@ def test_dont_trace_on_raise_with_tb(self): import sys l = [] - def ltrace(a,b,c): + def ltrace(a,b,c): if b == 'exception': l.append(c) return ltrace diff --git a/pypy/interpreter/test/test_zzpickle_and_slow.py b/pypy/interpreter/test/test_zzpickle_and_slow.py --- a/pypy/interpreter/test/test_zzpickle_and_slow.py +++ b/pypy/interpreter/test/test_zzpickle_and_slow.py @@ -3,7 +3,7 @@ from pypy.interpreter import gateway from rpython.rlib.jit import non_virtual_ref, vref_None -class AppTestSlow: +class AppTestSlow: spaceconfig = dict(usemodules=['itertools']) def setup_class(cls): @@ -64,7 +64,7 @@ space.setitem(space.builtin.w_dict, space.wrap('read_exc_type'), space.wrap(read_exc_type_gw)) - + def _detach_helpers(space): space.delitem(space.builtin.w_dict, space.wrap('hide_top_frame')) @@ -92,7 +92,7 @@ pckl = pickle.dumps(code) result = pickle.loads(pckl) assert code == result - + def test_pickle_global_func(self): import new mod = new.module('mod') @@ -109,7 +109,7 @@ assert func is result finally: del sys.modules['mod'] - + def test_pickle_not_imported_module(self): import new mod = new.module('mod') @@ -119,13 +119,13 @@ result = pickle.loads(pckl) assert mod.__name__ == result.__name__ assert mod.__dict__ == result.__dict__ - + def test_pickle_builtin_func(self): import pickle pckl = pickle.dumps(map) result = pickle.loads(pckl) assert map is result - + def test_pickle_non_top_reachable_func(self): def func(): return 42 @@ -142,7 +142,7 @@ assert func.func_dict == result.func_dict assert func.func_doc == result.func_doc assert func.func_globals == result.func_globals - + def test_pickle_cell(self): def g(): x = [42] @@ -171,7 +171,7 @@ f1 = f() saved = hide_top_frame(f1) pckl = pickle.dumps(f1) - restore_top_frame(f1, saved) + restore_top_frame(f1, saved) f2 = pickle.loads(pckl) assert type(f1) is type(f2) @@ -223,7 +223,7 @@ f1 = f() saved = hide_top_frame(f1) pckl = pickle.dumps(f1) - restore_top_frame(f1, saved) + restore_top_frame(f1, saved) f2 = pickle.loads(pckl) def test_frame_setstate_crash(self): @@ -257,21 +257,21 @@ pckl = pickle.dumps(mod) result = pickle.loads(pckl) assert mod is result - + def test_pickle_moduledict(self): import pickle moddict = pickle.__dict__ pckl = pickle.dumps(moddict) result = pickle.loads(pckl) assert moddict is result - + def test_pickle_bltins_module(self): import pickle mod = __builtins__ pckl = pickle.dumps(mod) result = pickle.loads(pckl) assert mod is result - + def test_pickle_buffer(self): skip("Can't pickle buffer objects on top of CPython either. " "Do we really need it?") @@ -280,14 +280,14 @@ pckl = pickle.dumps(a) result = pickle.loads(pckl) assert a == result - + def test_pickle_complex(self): import pickle a = complex(1.23,4.567) pckl = pickle.dumps(a) result = pickle.loads(pckl) assert a == result - + def test_pickle_method(self): class myclass(object): def f(self): @@ -308,7 +308,7 @@ assert method() == result() finally: del sys.modules['mod'] - + def test_pickle_staticmethod(self): class myclass(object): def f(): @@ -319,7 +319,7 @@ pckl = pickle.dumps(method) result = pickle.loads(pckl) assert method() == result() - + def test_pickle_classmethod(self): class myclass(object): def f(cls): @@ -337,7 +337,7 @@ assert method() == result() finally: del sys.modules['mod'] - + def test_pickle_sequenceiter(self): ''' In PyPy there is no distinction here between listiterator and diff --git a/pypy/module/__pypy__/interp_intop.py b/pypy/module/__pypy__/interp_intop.py --- a/pypy/module/__pypy__/interp_intop.py +++ b/pypy/module/__pypy__/interp_intop.py @@ -2,21 +2,10 @@ from rpython.rtyper.lltypesystem import lltype from rpython.rtyper.lltypesystem.lloperation import llop from rpython.rlib.rarithmetic import r_uint, intmask +from rpython.rlib.rarithmetic import int_c_div, int_c_mod from rpython.rlib import jit -# XXX maybe temporary: hide llop.int_{floordiv,mod} from the JIT, -# because now it expects only Python-style divisions, not the -# C-style divisions of these two ll operations -@jit.dont_look_inside -def _int_floordiv(n, m): - return llop.int_floordiv(lltype.Signed, n, m) - -@jit.dont_look_inside -def _int_mod(n, m): - return llop.int_mod(lltype.Signed, n, m) - - @unwrap_spec(n=int, m=int) def int_add(space, n, m): return space.wrap(llop.int_add(lltype.Signed, n, m)) @@ -31,11 +20,11 @@ @unwrap_spec(n=int, m=int) def int_floordiv(space, n, m): - return space.wrap(_int_floordiv(n, m)) + return space.wrap(int_c_div(n, m)) @unwrap_spec(n=int, m=int) def int_mod(space, n, m): - return space.wrap(_int_mod(n, m)) + return space.wrap(int_c_mod(n, m)) @unwrap_spec(n=int, m=int) def int_lshift(space, n, m): 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 -VERSION = "1.6.0" +VERSION = "1.7.0" FFI_DEFAULT_ABI = clibffi.FFI_DEFAULT_ABI try: diff --git a/pypy/module/_cffi_backend/ccallback.py b/pypy/module/_cffi_backend/ccallback.py --- a/pypy/module/_cffi_backend/ccallback.py +++ b/pypy/module/_cffi_backend/ccallback.py @@ -220,6 +220,11 @@ if rffi.cast(lltype.Signed, res) != clibffi.FFI_OK: raise oefmt(space.w_SystemError, "libffi failed to build this callback") + if closure_ptr.c_user_data != unique_id: + raise oefmt(space.w_SystemError, + "ffi_prep_closure(): bad user_data (it seems that the " + "version of the libffi library seen at runtime is " + "different from the 'ffi.h' file seen at compile-time)") def py_invoke(self, ll_res, ll_args): jitdriver1.jit_merge_point(callback=self, diff --git a/pypy/module/_cffi_backend/cdataobj.py b/pypy/module/_cffi_backend/cdataobj.py --- a/pypy/module/_cffi_backend/cdataobj.py +++ b/pypy/module/_cffi_backend/cdataobj.py @@ -420,6 +420,14 @@ w_result = ctype.ctitem.unpack_ptr(ctype, ptr, length) return w_result + def dir(self, space): + from pypy.module._cffi_backend.ctypeptr import W_CTypePointer + ct = self.ctype + if isinstance(ct, W_CTypePointer): + ct = ct.ctitem + lst = ct.cdata_dir() + return space.newlist([space.wrap(s) for s in lst]) + class W_CDataMem(W_CData): """This is used only by the results of cffi.cast('int', x) @@ -602,5 +610,6 @@ __call__ = interp2app(W_CData.call), __iter__ = interp2app(W_CData.iter), __weakref__ = make_weakref_descr(W_CData), + __dir__ = interp2app(W_CData.dir), ) W_CData.typedef.acceptable_as_base_class = False diff --git a/pypy/module/_cffi_backend/ctypeobj.py b/pypy/module/_cffi_backend/ctypeobj.py --- a/pypy/module/_cffi_backend/ctypeobj.py +++ b/pypy/module/_cffi_backend/ctypeobj.py @@ -256,6 +256,9 @@ def fget_elements(self, space): return self._fget('e') def fget_relements(self, space):return self._fget('R') + def cdata_dir(self): + return [] + W_CType.typedef = TypeDef( '_cffi_backend.CTypeDescr', diff --git a/pypy/module/_cffi_backend/ctypestruct.py b/pypy/module/_cffi_backend/ctypestruct.py --- a/pypy/module/_cffi_backend/ctypestruct.py +++ b/pypy/module/_cffi_backend/ctypestruct.py @@ -171,6 +171,12 @@ pass return W_CType.getcfield(self, attr) + def cdata_dir(self): + if self.size < 0: + return [] + self.force_lazy_struct() + return self._fields_dict.keys() + class W_CTypeStruct(W_CTypeStructOrUnion): kind = "struct" diff --git a/pypy/module/_cffi_backend/func.py b/pypy/module/_cffi_backend/func.py --- a/pypy/module/_cffi_backend/func.py +++ b/pypy/module/_cffi_backend/func.py @@ -201,6 +201,9 @@ else: copy_string_to_raw(llstr(src_string), dest_data, 0, n) else: + # nowadays this case should be rare or impossible: as far as + # I know, all common types implementing the *writable* buffer + # interface now support get_raw_address() if src_is_ptr: for i in range(n): dest_buf.setitem(i, src_data[i]) diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py --- a/pypy/module/_cffi_backend/test/_backend_test_c.py +++ b/pypy/module/_cffi_backend/test/_backend_test_c.py @@ -1,7 +1,7 @@ # ____________________________________________________________ import sys -assert __version__ == "1.6.0", ("This test_c.py file is for testing a version" +assert __version__ == "1.7.0", ("This test_c.py file is for testing a version" " of cffi that differs from the one that we" " get from 'import _cffi_backend'") if sys.version_info < (3,): @@ -77,8 +77,8 @@ assert repr(p) == "<ctype 'signed char'>" def check_dir(p, expected): - got = set(name for name in dir(p) if not name.startswith('_')) - assert got == set(expected) + got = [name for name in dir(p) if not name.startswith('_')] + assert got == sorted(expected) def test_inspect_primitive_type(): p = new_primitive_type("signed char") @@ -3608,3 +3608,23 @@ # py.test.raises(ValueError, unpack, p0, -1) py.test.raises(ValueError, unpack, p, -1) + +def test_cdata_dir(): + BInt = new_primitive_type("int") + p = cast(BInt, 42) + check_dir(p, []) + p = newp(new_array_type(new_pointer_type(BInt), None), 5) + check_dir(p, []) + BStruct = new_struct_type("foo") + p = cast(new_pointer_type(BStruct), 0) + check_dir(p, []) # opaque + complete_struct_or_union(BStruct, [('a2', BInt, -1), + ('a1', BInt, -1)]) + check_dir(p, ['a1', 'a2']) # always sorted + p = newp(new_pointer_type(BStruct), None) + check_dir(p, ['a1', 'a2']) + check_dir(p[0], ['a1', 'a2']) + pp = newp(new_pointer_type(new_pointer_type(BStruct)), p) + check_dir(pp, []) + check_dir(pp[0], ['a1', 'a2']) + check_dir(pp[0][0], ['a1', 'a2']) diff --git a/pypy/module/_socket/test/test_sock_app.py b/pypy/module/_socket/test/test_sock_app.py --- a/pypy/module/_socket/test/test_sock_app.py +++ b/pypy/module/_socket/test/test_sock_app.py @@ -671,13 +671,11 @@ class AppTestSocketTCP: HOST = 'localhost' - - def setup_class(cls): - cls.space = space + spaceconfig = {'usemodules': ['_socket', 'array']} def setup_method(self, method): - w_HOST = space.wrap(self.HOST) - self.w_serv = space.appexec([w_socket, w_HOST], + w_HOST = self.space.wrap(self.HOST) + self.w_serv =self.space.appexec([w_socket, w_HOST], '''(_socket, HOST): serv = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM) serv.bind((HOST, 0)) @@ -687,7 +685,7 @@ def teardown_method(self, method): if hasattr(self, 'w_serv'): - space.appexec([self.w_serv], '(serv): serv.close()') + self.space.appexec([self.w_serv], '(serv): serv.close()') self.w_serv = None def test_timeout(self): @@ -803,8 +801,7 @@ class AppTestErrno: - def setup_class(cls): - cls.space = space + spaceconfig = {'usemodules': ['_socket']} def test_errno(self): from socket import socket, AF_INET, SOCK_STREAM, error diff --git a/pypy/module/_vmprof/test/test__vmprof.py b/pypy/module/_vmprof/test/test__vmprof.py --- a/pypy/module/_vmprof/test/test__vmprof.py +++ b/pypy/module/_vmprof/test/test__vmprof.py @@ -3,8 +3,9 @@ from pypy.tool.pytest.objspace import gettestobjspace class AppTestVMProf(object): + spaceconfig = {'usemodules': ['_vmprof', 'struct']} + def setup_class(cls): - cls.space = gettestobjspace(usemodules=['_vmprof', 'struct']) cls.w_tmpfilename = cls.space.wrap(str(udir.join('test__vmprof.1'))) cls.w_tmpfilename2 = cls.space.wrap(str(udir.join('test__vmprof.2'))) @@ -17,7 +18,7 @@ import struct, sys, gc WORD = struct.calcsize('l') - + def count(s): i = 0 count = 0 @@ -44,7 +45,7 @@ else: raise AssertionError(ord(s[i])) return count - + import _vmprof gc.collect() # try to make the weakref list deterministic gc.collect() # by freeing all dead code objects 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 @@ -1512,7 +1512,7 @@ try: ll_libname = rffi.str2charp(path) try: - dll = rdynload.dlopen(ll_libname) + dll = rdynload.dlopen(ll_libname, space.sys.dlopenflags) finally: lltype.free(ll_libname, flavor='raw') except rdynload.DLOpenError as e: 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 @@ -29,8 +29,8 @@ #define PY_VERSION "2.7.10" /* PyPy version as a string */ -#define PYPY_VERSION "5.3.0-alpha0" -#define PYPY_VERSION_NUM 0x05030000 +#define PYPY_VERSION "5.3.1-alpha0" +#define PYPY_VERSION_NUM 0x05030100 /* 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/cpyext/include/pymem.h b/pypy/module/cpyext/include/pymem.h --- a/pypy/module/cpyext/include/pymem.h +++ b/pypy/module/cpyext/include/pymem.h @@ -1,5 +1,11 @@ #include <stdlib.h> +#ifndef Py_PYMEM_H +#define Py_PYMEM_H + +#ifdef __cplusplus +extern "C" { +#endif #define PyMem_MALLOC(n) malloc((n) ? (n) : 1) #define PyMem_REALLOC(p, n) realloc((p), (n) ? (n) : 1) @@ -44,3 +50,9 @@ */ #define PyMem_Del PyMem_Free #define PyMem_DEL PyMem_FREE + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_PYMEM_H */ diff --git a/pypy/module/cpyext/object.py b/pypy/module/cpyext/object.py --- a/pypy/module/cpyext/object.py +++ b/pypy/module/cpyext/object.py @@ -1,7 +1,7 @@ from rpython.rtyper.lltypesystem import rffi, lltype from pypy.module.cpyext.api import ( cpython_api, generic_cpy_call, CANNOT_FAIL, Py_ssize_t, Py_ssize_tP, - PyVarObject, Py_buffer, + PyVarObject, Py_buffer, size_t, Py_TPFLAGS_HEAPTYPE, Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE, CONST_STRING, FILEP, fwrite) from pypy.module.cpyext.pyobject import ( @@ -14,14 +14,14 @@ import pypy.module.__builtin__.operation as operation -@cpython_api([Py_ssize_t], rffi.VOIDP) +@cpython_api([size_t], rffi.VOIDP) def PyObject_Malloc(space, size): # returns non-zero-initialized memory, like CPython return lltype.malloc(rffi.VOIDP.TO, size, flavor='raw', add_memory_pressure=True) -@cpython_api([rffi.VOIDP, Py_ssize_t], rffi.VOIDP) +@cpython_api([rffi.VOIDP, size_t], rffi.VOIDP) def PyObject_Realloc(space, ptr, size): if not lltype.cast_ptr_to_int(ptr): return lltype.malloc(rffi.VOIDP.TO, size, diff --git a/pypy/module/imp/test/test_import.py b/pypy/module/imp/test/test_import.py --- a/pypy/module/imp/test/test_import.py +++ b/pypy/module/imp/test/test_import.py @@ -143,7 +143,7 @@ def _setup(space): dn = setup_directory_structure(space) return space.appexec([space.wrap(dn)], """ - (dn): + (dn): import sys path = list(sys.path) sys.path.insert(0, dn) @@ -1017,7 +1017,7 @@ cpathname = udir.join('test.pyc') assert not cpathname.check() - + def test_load_source_module_importerror(self): # the .pyc file is created before executing the module space = self.space @@ -1126,11 +1126,11 @@ stream.close() -def test_PYTHONPATH_takes_precedence(space): +def test_PYTHONPATH_takes_precedence(space): if sys.platform == "win32": py.test.skip("unresolved issues with win32 shell quoting rules") - from pypy.interpreter.test.test_zpy import pypypath - extrapath = udir.ensure("pythonpath", dir=1) + from pypy.interpreter.test.test_zpy import pypypath + extrapath = udir.ensure("pythonpath", dir=1) extrapath.join("sched.py").write("print 42\n") old = os.environ.get('PYTHONPATH', None) oldlang = os.environ.pop('LANG', None) diff --git a/pypy/module/micronumpy/test/test_complex.py b/pypy/module/micronumpy/test/test_complex.py --- a/pypy/module/micronumpy/test/test_complex.py +++ b/pypy/module/micronumpy/test/test_complex.py @@ -495,8 +495,8 @@ c = array([1.e+110, 1.e-110], dtype=complex128) d = floor_divide(c**2, c) assert (d == [1.e+110, 0]).all() - - + + def test_basic(self): import sys diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py --- a/pypy/module/micronumpy/test/test_dtypes.py +++ b/pypy/module/micronumpy/test/test_dtypes.py @@ -372,8 +372,8 @@ a = np.array(data, dtype=b) x = pickle.loads(pickle.dumps(a)) assert (x == a).all() - assert x.dtype == a.dtype - + assert x.dtype == a.dtype + def test_index(self): import numpy as np for dtype in [np.int8, np.int16, np.int32, np.int64]: @@ -1459,7 +1459,7 @@ "'offsets':[0,76800], " "'itemsize':80000, " "'aligned':True}") - + assert dt == np.dtype(eval(str(dt))) dt = np.dtype({'names': ['r', 'g', 'b'], 'formats': ['u1', 'u1', 'u1'], diff --git a/pypy/module/micronumpy/test/test_ndarray.py b/pypy/module/micronumpy/test/test_ndarray.py --- a/pypy/module/micronumpy/test/test_ndarray.py +++ b/pypy/module/micronumpy/test/test_ndarray.py @@ -1878,7 +1878,7 @@ assert map(isnan, e) == [False, False, False, True, False] assert map(isinf, e) == [False, False, True, False, False] assert e.argmax() == 3 - # numpy preserves value for uint16 -> cast_as_float16 -> + # numpy preserves value for uint16 -> cast_as_float16 -> # convert_to_float64 -> convert_to_float16 -> uint16 # even for float16 various float16 nans all_f16 = arange(0xfe00, 0xffff, dtype='uint16') @@ -2608,7 +2608,7 @@ a = np.arange(6).reshape(2,3) i = np.dtype('int32').type(0) assert (a[0] == a[i]).all() - + def test_ellipsis_indexing(self): import numpy as np diff --git a/pypy/module/micronumpy/test/test_object_arrays.py b/pypy/module/micronumpy/test/test_object_arrays.py --- a/pypy/module/micronumpy/test/test_object_arrays.py +++ b/pypy/module/micronumpy/test/test_object_arrays.py @@ -200,7 +200,7 @@ from numpy import arange, dtype from cPickle import loads, dumps import sys - + a = arange(15).astype(object) if '__pypy__' in sys.builtin_module_names: raises(NotImplementedError, dumps, a) @@ -211,4 +211,4 @@ a = arange(15).astype(object).reshape((3, 5)) b = loads(dumps(a)) assert (a == b).all() - + diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py --- a/pypy/module/posix/test/test_posix2.py +++ b/pypy/module/posix/test/test_posix2.py @@ -13,14 +13,15 @@ import sys import signal +USEMODULES = ['binascii', 'posix', 'struct', 'time'] +if os.name != 'nt': + USEMODULES += ['fcntl'] +else: + # On windows, os.popen uses the subprocess module + USEMODULES += ['_rawffi', 'thread', 'signal'] + def setup_module(mod): - usemodules = ['binascii', 'posix', 'struct', 'time'] - if os.name != 'nt': - usemodules += ['fcntl'] - else: - # On windows, os.popen uses the subprocess module - usemodules += ['_rawffi', 'thread', 'signal'] - mod.space = gettestobjspace(usemodules=usemodules) + mod.space = gettestobjspace(usemodules=USEMODULES) mod.path = udir.join('posixtestfile.txt') mod.path.write("this is a test") mod.path2 = udir.join('test_posix2-') @@ -49,9 +50,10 @@ class AppTestPosix: + spaceconfig = {'usemodules': USEMODULES} def setup_class(cls): - cls.space = space + space = cls.space cls.w_runappdirect = space.wrap(cls.runappdirect) cls.w_posix = space.appexec([], GET_POSIX) cls.w_path = space.wrap(str(path)) @@ -1145,14 +1147,10 @@ class AppTestEnvironment(object): def setup_class(cls): - cls.space = space - cls.w_posix = space.appexec([], "(): import %s as m ; return m" % os.name) - cls.w_os = space.appexec([], "(): import os; return os") cls.w_path = space.wrap(str(path)) def test_environ(self): - posix = self.posix - os = self.os + import posix assert posix.environ['PATH'] del posix.environ['PATH'] def fn(): posix.environ['PATH'] @@ -1160,7 +1158,7 @@ if hasattr(__import__(os.name), "unsetenv"): def test_unsetenv_nonexisting(self): - os = self.os + import os os.unsetenv("XYZABC") #does not raise try: os.environ["ABCABC"] @@ -1178,8 +1176,6 @@ class AppTestPosixUnicode: def setup_class(cls): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit