[pypy-commit] pypy py3.6: hg merge py3.5
Author: ukasz Langa Branch: py3.6 Changeset: r95864:baff18bae4fb Date: 2019-02-06 12:01 +0100 http://bitbucket.org/pypy/pypy/changeset/baff18bae4fb/ Log:hg merge py3.5 diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -4,8 +4,10 @@ *~ .*.swp .idea +.mypy_cache .project .pydevproject +.vscode __pycache__ .venv .cache diff --git a/lib_pypy/_csv.py b/lib_pypy/_csv.py deleted file mode 100644 --- a/lib_pypy/_csv.py +++ /dev/null @@ -1,573 +0,0 @@ -"""CSV parsing and writing. - -This module provides classes that assist in the reading and writing -of Comma Separated Value (CSV) files, and implements the interface -described by PEP 305. Although many CSV files are simple to parse, -the format is not formally defined by a stable specification and -is subtle enough that parsing lines of a CSV file with something -like line.split(\",\") is bound to fail. The module supports three -basic APIs: reading, writing, and registration of dialects. - - -DIALECT REGISTRATION: - -Readers and writers support a dialect argument, which is a convenient -handle on a group of settings. When the dialect argument is a string, -it identifies one of the dialects previously registered with the module. -If it is a class or instance, the attributes of the argument are used as -the settings for the reader or writer: - -class excel: -delimiter = ',' -quotechar = '\"' -escapechar = None -doublequote = True -skipinitialspace = False -lineterminator = '\\r\\n' -quoting = QUOTE_MINIMAL - -SETTINGS: - -* quotechar - specifies a one-character string to use as the -quoting character. It defaults to '\"'. -* delimiter - specifies a one-character string to use as the -field separator. It defaults to ','. -* skipinitialspace - specifies how to interpret whitespace which -immediately follows a delimiter. It defaults to False, which -means that whitespace immediately following a delimiter is part -of the following field. -* lineterminator - specifies the character sequence which should -terminate rows. -* quoting - controls when quotes should be generated by the writer. -It can take on any of the following module constants: - -csv.QUOTE_MINIMAL means only when required, for example, when a -field contains either the quotechar or the delimiter -csv.QUOTE_ALL means that quotes are always placed around fields. -csv.QUOTE_NONNUMERIC means that quotes are always placed around -fields which do not parse as integers or floating point -numbers. -csv.QUOTE_NONE means that quotes are never placed around fields. -* escapechar - specifies a one-character string used to escape -the delimiter when quoting is set to QUOTE_NONE. -* doublequote - controls the handling of quotes inside fields. When -True, two consecutive quotes are interpreted as one during read, -and when writing, each quote character embedded in the data is -written as two quotes. -""" - -__version__ = "1.0" - -QUOTE_MINIMAL, QUOTE_ALL, QUOTE_NONNUMERIC, QUOTE_NONE = range(4) -_dialects = {} -_field_limit = 128 * 1024 # max parsed field size - -class Error(Exception): -pass - -class Dialect(object): -"""CSV dialect - -The Dialect type records CSV parsing and generation options.""" - -__slots__ = ["_delimiter", "_doublequote", "_escapechar", - "_lineterminator", "_quotechar", "_quoting", - "_skipinitialspace", "_strict"] - -def __new__(cls, dialect, **kwargs): - -for name in kwargs: -if '_' + name not in Dialect.__slots__: -raise TypeError("unexpected keyword argument '%s'" % -(name,)) - -if dialect is not None: -if isinstance(dialect, str): -dialect = get_dialect(dialect) - -# Can we reuse this instance? -if (isinstance(dialect, Dialect) -and all(value is None for value in kwargs.values())): -return dialect - -self = object.__new__(cls) - - -def set_char(x): -if x is None: -return None -if isinstance(x, str) and len(x) <= 1: -return x -raise TypeError("%r must be a 1-character string" % (name,)) -def set_str(x): -if isinstance(x, str): -return x -raise TypeError("%r must be a string" % (name,)) -def set_quoting(x): -if x in range(4): -return x -raise TypeError("bad 'quoting' value") - -attributes = {"delimiter": (',', set_char), - "doublequote": (True, bool), - "escapechar": (None, set_char), - "lineterminator": ("\r\n", set_str), -
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Antonio Cuni Branch: py3.6 Changeset: r95773:b1506a30f188 Date: 2019-02-01 18:59 +0100 http://bitbucket.org/pypy/pypy/changeset/b1506a30f188/ Log:hg merge py3.5 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 Schnenberg 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 Hronok + 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 Gaczyski + 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 Hronok - Anthony Sottile - Nate Bragg + Andrew Stepanov + Rafa Gaczyski 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 Arajo @@ -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
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Ronan Lamy Branch: py3.6 Changeset: r95743:c5adb85f6de1 Date: 2019-01-28 19:02 + http://bitbucket.org/pypy/pypy/changeset/c5adb85f6de1/ Log:hg merge py3.5 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/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 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Amaury Forgeot d'Arc Branch: py3.6 Changeset: r95559:df0beeb7b5ec Date: 2019-01-01 18:50 +0100 http://bitbucket.org/pypy/pypy/changeset/df0beeb7b5ec/ Log:hg merge py3.5 diff --git a/LICENSE b/LICENSE --- a/LICENSE +++ b/LICENSE @@ -30,7 +30,7 @@ DEALINGS IN THE SOFTWARE. -PyPy Copyright holders 2003-2018 +PyPy Copyright holders 2003-2019 Except when otherwise stated (look for LICENSE files or information at diff --git a/extra_tests/cffi_tests/cffi0/test_ffi_backend.py b/extra_tests/cffi_tests/cffi0/test_ffi_backend.py --- a/extra_tests/cffi_tests/cffi0/test_ffi_backend.py +++ b/extra_tests/cffi_tests/cffi0/test_ffi_backend.py @@ -327,6 +327,16 @@ assert ffi.typeof(c) is ffi.typeof("char[]") ffi.cast("unsigned short *", c)[1] += 500 assert list(a) == [1, 20500, 3] +assert c == ffi.from_buffer(a, True) +assert c == ffi.from_buffer(a, require_writable=True) +# +p = ffi.from_buffer(b"abcd") +assert p[2] == b"c" +# +assert p == ffi.from_buffer(b"abcd", False) +py.test.raises((TypeError, BufferError), ffi.from_buffer, b"abcd", True) +py.test.raises((TypeError, BufferError), ffi.from_buffer, b"abcd", + require_writable=True) def test_memmove(self): ffi = FFI() diff --git a/extra_tests/cffi_tests/cffi1/test_ffi_obj.py b/extra_tests/cffi_tests/cffi1/test_ffi_obj.py --- a/extra_tests/cffi_tests/cffi1/test_ffi_obj.py +++ b/extra_tests/cffi_tests/cffi1/test_ffi_obj.py @@ -244,6 +244,16 @@ assert ffi.typeof(c) is ffi.typeof("char[]") ffi.cast("unsigned short *", c)[1] += 500 assert list(a) == [1, 20500, 3] +assert c == ffi.from_buffer(a, True) +assert c == ffi.from_buffer(a, require_writable=True) +# +p = ffi.from_buffer(b"abcd") +assert p[2] == b"c" +# +assert p == ffi.from_buffer(b"abcd", False) +py.test.raises((TypeError, BufferError), ffi.from_buffer, b"abcd", True) +py.test.raises((TypeError, BufferError), ffi.from_buffer, b"abcd", + require_writable=True) def test_memmove(): ffi = _cffi1_backend.FFI() diff --git a/extra_tests/cffi_tests/cffi1/test_new_ffi_1.py b/extra_tests/cffi_tests/cffi1/test_new_ffi_1.py --- a/extra_tests/cffi_tests/cffi1/test_new_ffi_1.py +++ b/extra_tests/cffi_tests/cffi1/test_new_ffi_1.py @@ -1654,6 +1654,16 @@ assert ffi.typeof(c) is ffi.typeof("char[]") ffi.cast("unsigned short *", c)[1] += 500 assert list(a) == [1, 20500, 3] +assert c == ffi.from_buffer(a, True) +assert c == ffi.from_buffer(a, require_writable=True) +# +p = ffi.from_buffer(b"abcd") +assert p[2] == b"c" +# +assert p == ffi.from_buffer(b"abcd", False) +py.test.raises((TypeError, BufferError), ffi.from_buffer, b"abcd", True) +py.test.raises((TypeError, BufferError), ffi.from_buffer, b"abcd", + require_writable=True) def test_all_primitives(self): assert set(PRIMITIVE_TO_INDEX) == set([ diff --git a/extra_tests/test_pyrepl/conftest.py b/extra_tests/test_pyrepl/conftest.py new file mode 100644 --- /dev/null +++ b/extra_tests/test_pyrepl/conftest.py @@ -0,0 +1,8 @@ +import sys + +def pytest_ignore_collect(path): +if '__pypy__' not in sys.builtin_module_names: +try: +import pyrepl +except ImportError: +return True diff --git a/lib-python/3/datetime.py b/lib-python/3/datetime.py --- a/lib-python/3/datetime.py +++ b/lib-python/3/datetime.py @@ -537,7 +537,11 @@ -self._microseconds) def __pos__(self): -return self +# for CPython compatibility, we cannot use +# our __class__ here, but need a real timedelta +return timedelta(self._days, + self._seconds, + self._microseconds) def __abs__(self): if self._days < 0: @@ -829,8 +833,7 @@ month = self._month if day is None: day = self._day -# PyPy fix: returns type(self)() instead of date() -return type(self)(year, month, day) +return date.__new__(type(self), year, month, day) # Comparisons of date objects with other. @@ -1323,8 +1326,8 @@ tzinfo = self.tzinfo if fold is None: fold = self._fold -# PyPy fix: returns type(self)() instead of time() -return type(self)(hour, minute, second, microsecond, tzinfo, fold=fold) +return time.__new__(type(self), +hour, minute, second, microsecond, tzinfo) # Pickle support. @@ -1387,13 +1390,13 @@ hour, minute, second, microsecond, fold) _check_tzinfo_arg(tzinfo) self =
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Ronan Lamy Branch: py3.6 Changeset: r95167:6ffaea666f35 Date: 2018-09-25 19:18 +0100 http://bitbucket.org/pypy/pypy/changeset/6ffaea666f35/ Log:hg merge py3.5 diff --git a/README.rst b/README.rst --- a/README.rst +++ b/README.rst @@ -4,7 +4,7 @@ Welcome to PyPy! -PyPy is an interperter that implements the Python programming language, based +PyPy is an interpreter that implements the Python programming language, based on the RPython compiler framework for dynamic language implementations. The home page for the interpreter is: @@ -15,29 +15,29 @@ http://doc.pypy.org/ -More documentation about the RPython framework can be found here +More documentation about the RPython framework can be found here: -http://rpython.readthedocs.io +http://rpython.readthedocs.io/ -The source for the documentation is in the pypy/doc directory +The source for the documentation is in the pypy/doc directory. + Using PyPy instead of CPython -= +- -Please read the information at http://pypy.org to find the correct way to +Please read the information at http://pypy.org/ to find the correct way to download and use PyPy as an alternative to CPython. + Building - + Building PyPy is not the recommended way to obtain the PyPy alternative python interpreter. It is time-consuming and requires significant computing resources. -More information can be found here +More information can be found here: http://doc.pypy.org/en/latest/build.html Enjoy and send us feedback! the pypy-dev team - - diff --git a/lib-python/3/test/test_inspect.py b/lib-python/3/test/test_inspect.py --- a/lib-python/3/test/test_inspect.py +++ b/lib-python/3/test/test_inspect.py @@ -61,6 +61,9 @@ git = mod.StupidGit() +class ExampleClassWithSlot(object): +__slots__ = 'myslot' + class IsTestBase(unittest.TestCase): predicates = set([inspect.isbuiltin, inspect.isclass, inspect.iscode, inspect.isframe, inspect.isfunction, inspect.ismethod, @@ -141,8 +144,11 @@ self.istest(inspect.iscoroutinefunction, 'coroutine_function_example') if hasattr(types, 'MemberDescriptorType'): -self.istest(inspect.ismemberdescriptor, -'type(lambda: None).__globals__') +# App-level slots are member descriptors on both PyPy and +# CPython, but the various built-in attributes are all +# getsetdescriptors on PyPy. So check ismemberdescriptor() +# with an app-level slot. +self.istest(inspect.ismemberdescriptor, 'ExampleClassWithSlot.myslot') else: self.assertFalse(inspect.ismemberdescriptor(datetime.timedelta.days)) diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py --- a/lib_pypy/_ctypes/function.py +++ b/lib_pypy/_ctypes/function.py @@ -486,6 +486,8 @@ return cobj, cobj._to_ffi_param(), type(cobj) def _convert_args_for_callback(self, argtypes, args): +from _ctypes.structure import StructOrUnion +# assert len(argtypes) == len(args) newargs = [] for argtype, arg in zip(argtypes, args): @@ -495,6 +497,10 @@ param = param._get_buffer_value() elif self._is_primitive(argtype): param = param.value +elif isinstance(param, StructOrUnion): # not a *pointer* to struct +newparam = StructOrUnion.__new__(type(param)) +param._copy_to(newparam._buffer.buffer) +param = newparam newargs.append(param) return newargs diff --git a/lib_pypy/cffi/setuptools_ext.py b/lib_pypy/cffi/setuptools_ext.py --- a/lib_pypy/cffi/setuptools_ext.py +++ b/lib_pypy/cffi/setuptools_ext.py @@ -162,6 +162,17 @@ module_path = module_name.split('.') module_path[-1] += '.py' generate_mod(os.path.join(self.build_lib, *module_path)) +def get_source_files(self): +# This is called from 'setup.py sdist' only. Exclude +# the generate .py module in this case. +saved_py_modules = self.py_modules +try: +if saved_py_modules: +self.py_modules = [m for m in saved_py_modules + if m != module_name] +return base_class.get_source_files(self) +finally: +self.py_modules = saved_py_modules dist.cmdclass['build_py'] = build_py_make_mod # distutils and setuptools have no notion I could find of a @@ -171,6 +182,7 @@ # the module. So we add it here, which gives a few apparently # harmless warnings about not finding the file outside the # build directory. +# Then we need to hack more in get_source_files(); see above. if dist.py_modules is None: dist.py_modules = []
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Ronan Lamy Branch: py3.6 Changeset: r95139:39e4b5e92c6c Date: 2018-09-19 02:26 +0100 http://bitbucket.org/pypy/pypy/changeset/39e4b5e92c6c/ Log:hg merge py3.5 diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst --- a/pypy/doc/cpython_differences.rst +++ b/pypy/doc/cpython_differences.rst @@ -330,7 +330,8 @@ - * Hash randomization (``-R``) `is ignored in PyPy`_. In CPython - before 3.4 it has `little point`_. + before 3.4 it has `little point`_. Both CPython >= 3.4 and PyPy3 + implement the randomized SipHash algorithm and ignore ``-R``. * You can't store non-string keys in type objects. For example:: diff --git a/pypy/module/_csv/interp_reader.py b/pypy/module/_csv/interp_reader.py --- a/pypy/module/_csv/interp_reader.py +++ b/pypy/module/_csv/interp_reader.py @@ -73,6 +73,9 @@ break raise self.line_num += 1 +if space.isinstance_w(w_line, space.w_bytes): +raise self.error(u"iterator should return strings, not bytes " + u"(did you open the file in text mode?") line = space.unicode_w(w_line) for c in line: if c == u'\0': diff --git a/pypy/module/_csv/test/test_reader.py b/pypy/module/_csv/test/test_reader.py --- a/pypy/module/_csv/test/test_reader.py +++ b/pypy/module/_csv/test/test_reader.py @@ -33,7 +33,7 @@ def test_cannot_read_bytes(self): import _csv reader = _csv.reader([b'foo']) -raises((TypeError, _csv.Error), next, reader) +raises(_csv.Error, next, reader) def test_read_oddinputs(self): self._read_test([], []) diff --git a/pypy/module/cpyext/test0/test_arraymodule.py b/pypy/module/cpyext/test/test_arraymodule.py rename from pypy/module/cpyext/test0/test_arraymodule.py rename to pypy/module/cpyext/test/test_arraymodule.py diff --git a/pypy/module/cpyext/test0/test_boolobject.py b/pypy/module/cpyext/test/test_boolobject.py rename from pypy/module/cpyext/test0/test_boolobject.py rename to pypy/module/cpyext/test/test_boolobject.py diff --git a/pypy/module/cpyext/test0/test_borrow.py b/pypy/module/cpyext/test/test_borrow.py rename from pypy/module/cpyext/test0/test_borrow.py rename to pypy/module/cpyext/test/test_borrow.py diff --git a/pypy/module/cpyext/test0/test_bytearrayobject.py b/pypy/module/cpyext/test/test_bytearrayobject.py rename from pypy/module/cpyext/test0/test_bytearrayobject.py rename to pypy/module/cpyext/test/test_bytearrayobject.py diff --git a/pypy/module/cpyext/test0/test_bytesobject.py b/pypy/module/cpyext/test/test_bytesobject.py rename from pypy/module/cpyext/test0/test_bytesobject.py rename to pypy/module/cpyext/test/test_bytesobject.py diff --git a/pypy/module/cpyext/test0/test_capsule.py b/pypy/module/cpyext/test/test_capsule.py rename from pypy/module/cpyext/test0/test_capsule.py rename to pypy/module/cpyext/test/test_capsule.py diff --git a/pypy/module/cpyext/test0/test_cell.py b/pypy/module/cpyext/test/test_cell.py rename from pypy/module/cpyext/test0/test_cell.py rename to pypy/module/cpyext/test/test_cell.py diff --git a/pypy/module/cpyext/test0/test_classobject.py b/pypy/module/cpyext/test/test_classobject.py rename from pypy/module/cpyext/test0/test_classobject.py rename to pypy/module/cpyext/test/test_classobject.py diff --git a/pypy/module/cpyext/test0/test_codecs.py b/pypy/module/cpyext/test/test_codecs.py rename from pypy/module/cpyext/test0/test_codecs.py rename to pypy/module/cpyext/test/test_codecs.py diff --git a/pypy/module/cpyext/test0/test_complexobject.py b/pypy/module/cpyext/test/test_complexobject.py rename from pypy/module/cpyext/test0/test_complexobject.py rename to pypy/module/cpyext/test/test_complexobject.py diff --git a/pypy/module/cpyext/test0/test_cparser.py b/pypy/module/cpyext/test/test_cparser.py rename from pypy/module/cpyext/test0/test_cparser.py rename to pypy/module/cpyext/test/test_cparser.py diff --git a/pypy/module/cpyext/test0/test_datetime.py b/pypy/module/cpyext/test/test_datetime.py rename from pypy/module/cpyext/test0/test_datetime.py rename to pypy/module/cpyext/test/test_datetime.py diff --git a/pypy/module/cpyext/test0/test_dictobject.py b/pypy/module/cpyext/test/test_dictobject.py rename from pypy/module/cpyext/test0/test_dictobject.py rename to pypy/module/cpyext/test/test_dictobject.py diff --git a/pypy/module/cpyext/test0/test_eval.py b/pypy/module/cpyext/test/test_eval.py rename from pypy/module/cpyext/test0/test_eval.py rename to pypy/module/cpyext/test/test_eval.py diff --git a/pypy/module/cpyext/test0/test_fileobject.py b/pypy/module/cpyext/test/test_fileobject.py rename from pypy/module/cpyext/test0/test_fileobject.py rename to pypy/module/cpyext/test/test_fileobject.py diff --git a/pypy/module/cpyext/test0/test_floatobject.py b/pypy/module/cpyext/test/test_floatobject.py rename from
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Ronan Lamy Branch: py3.6 Changeset: r95059:3101fec75c3f Date: 2018-09-01 15:57 +0200 http://bitbucket.org/pypy/pypy/changeset/3101fec75c3f/ Log:hg merge py3.5 diff --git a/lib_pypy/_ctypes/array.py b/lib_pypy/_ctypes/array.py --- a/lib_pypy/_ctypes/array.py +++ b/lib_pypy/_ctypes/array.py @@ -189,6 +189,7 @@ self._buffer = self._ffiarray(self._length_, autofree=True) for i, arg in enumerate(args): self[i] = arg +_init_no_arg_ = __init__ def _fix_index(self, index): if index < 0: diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py --- a/lib_pypy/_ctypes/basics.py +++ b/lib_pypy/_ctypes/basics.py @@ -110,7 +110,7 @@ raise ValueError( "Buffer size too small (%d instead of at least %d bytes)" % (buf.nbytes, offset + size)) -result = self() +result = self._newowninstance_() dest = result._buffer.buffer try: raw_addr = buf._pypy_raw_address() + offset @@ -121,6 +121,11 @@ memmove(dest, raw_addr, size) return result +def _newowninstance_(self): +result = self.__new__(self) +result._init_no_arg_() +return result + class CArgObject(object): """ simple wrapper around buffer, just for the case of freeing @@ -151,6 +156,7 @@ def __init__(self, *args, **kwds): raise TypeError("%s has no type" % (type(self),)) +_init_no_arg_ = __init__ def _ensure_objects(self): if '_objects' not in self.__dict__: diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py --- a/lib_pypy/_ctypes/function.py +++ b/lib_pypy/_ctypes/function.py @@ -267,6 +267,7 @@ return raise TypeError("Unknown constructor %s" % (args,)) +_init_no_arg_ = __init__ def _wrap_callable(self, to_call, argtypes): def f(*args): @@ -557,7 +558,7 @@ keepalive, newarg, newargtype = self._conv_param(argtype, defval) else: import ctypes -val = argtype._type_() +val = argtype._type_._newowninstance_() keepalive = None newarg = ctypes.byref(val) newargtype = type(newarg) diff --git a/lib_pypy/_ctypes/pointer.py b/lib_pypy/_ctypes/pointer.py --- a/lib_pypy/_ctypes/pointer.py +++ b/lib_pypy/_ctypes/pointer.py @@ -67,8 +67,11 @@ self._buffer = ffiarray(1, autofree=True) if value is not None: self.contents = value +def _init_no_arg_(self): +self._buffer = ffiarray(1, autofree=True) self._ffiarray = ffiarray self.__init__ = __init__ +self._init_no_arg_ = _init_no_arg_ self._type_ = TP def _build_ffiargtype(self): @@ -136,27 +139,21 @@ if not (isinstance(tp, _CDataMeta) and tp._is_pointer_like()): raise TypeError("cast() argument 2 must be a pointer type, not %s" % (tp,)) +result = tp._newowninstance_() if isinstance(obj, int): -result = tp() result._buffer[0] = obj return result elif obj is None: -result = tp() return result elif isinstance(obj, Array): -ptr = tp.__new__(tp) -ptr._buffer = tp._ffiarray(1, autofree=True) -ptr._buffer[0] = obj._buffer -result = ptr +result._buffer[0] = obj._buffer elif isinstance(obj, bytes): -result = tp() result._buffer[0] = memoryview(obj)._pypy_raw_address() return result elif not (isinstance(obj, _CData) and type(obj)._is_pointer_like()): raise TypeError("cast() argument 1 must be a pointer, not %s" % (type(obj),)) else: -result = tp() result._buffer[0] = obj._buffer[0] # The casted objects '_objects' member: diff --git a/lib_pypy/_ctypes/primitive.py b/lib_pypy/_ctypes/primitive.py --- a/lib_pypy/_ctypes/primitive.py +++ b/lib_pypy/_ctypes/primitive.py @@ -378,11 +378,14 @@ self._buffer = self._ffiarray(1, autofree=True) if value is not DEFAULT_VALUE: self.value = value +_init_no_arg_ = __init__ def _ensure_objects(self): -if self._type_ not in 'zZP': -assert self._objects is None -return self._objects +# No '_objects' is the common case for primitives. Examples +# where there is an _objects is if _type in 'zZP', or if +# self comes from 'from_buffer(buf)'. See module/test_lib_pypy/ +# ctypes_test/test_buffers.py: test_from_buffer_keepalive. +return getattr(self, '_objects', None) def _getvalue(self): return self._buffer[0] diff --git a/lib_pypy/_ctypes/structure.py b/lib_pypy/_ctypes/structure.py --- a/lib_pypy/_ctypes/structure.py +++
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Ronan Lamy Branch: py3.6 Changeset: r95053:103458c3eab6 Date: 2018-08-31 15:00 +0200 http://bitbucket.org/pypy/pypy/changeset/103458c3eab6/ Log:hg merge py3.5 diff too long, truncating to 2000 out of 4177 lines diff --git a/lib-python/3/types.py b/lib-python/3/types.py --- a/lib-python/3/types.py +++ b/lib-python/3/types.py @@ -46,9 +46,19 @@ FrameType = type(tb.tb_frame) tb = None; del tb -# For Jython, the following two types are identical +# +# On CPython, FunctionType.__code__ is a 'getset_descriptor', but +# FunctionType.__globals__ is a 'member_descriptor', just like app-level +# slots. On PyPy, all descriptors of built-in types are +# 'getset_descriptor', but the app-level slots are 'member_descriptor' +# as well. (On Jython the situation might still be different.) +# +# Note that MemberDescriptorType was equal to GetSetDescriptorType in +# PyPy <= 6.0. +# GetSetDescriptorType = type(FunctionType.__code__) -MemberDescriptorType = type(FunctionType.__globals__) +class _C: __slots__ = 's' +MemberDescriptorType = type(_C.s) del sys, _f, _g, _C, _c, # Not for export diff --git a/lib_pypy/cffi/_cffi_errors.h b/lib_pypy/cffi/_cffi_errors.h --- a/lib_pypy/cffi/_cffi_errors.h +++ b/lib_pypy/cffi/_cffi_errors.h @@ -50,7 +50,9 @@ "import sys\n" "class FileLike:\n" " def write(self, x):\n" -"of.write(x)\n" +"try:\n" +" of.write(x)\n" +"except: pass\n" "self.buf += x\n" "fl = FileLike()\n" "fl.buf = ''\n" 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 @@ -8,20 +8,43 @@ the same works for the other two macros. Py_DEBUG implies them, but not the other way around. - Issue #350 is still open: on Windows, the code here causes it to link - with PYTHON36.DLL (for example) instead of PYTHON3.DLL. A fix was - attempted in 164e526a5515 and 14ce6985e1c3, but reverted: virtualenv - does not make PYTHON3.DLL available, and so the "correctly" compiled - version would not run inside a virtualenv. We will re-apply the fix - after virtualenv has been fixed for some time. For explanation, see - issue #355. For a workaround if you want PYTHON3.DLL and don't worry - about virtualenv, see issue #350. See also 'py_limited_api' in - setuptools_ext.py. + The implementation is messy (issue #350): on Windows, with _MSC_VER, + we have to define Py_LIMITED_API even before including pyconfig.h. + In that case, we guess what pyconfig.h will do to the macros above, + and check our guess after the #include. + + Note that on Windows, with CPython 3.x, you need virtualenv version + >= 16.0.0. Older versions don't copy PYTHON3.DLL. As a workaround + you can remove the definition of Py_LIMITED_API here. + + See also 'py_limited_api' in cffi/setuptools_ext.py. */ #if !defined(_CFFI_USE_EMBEDDING) && !defined(Py_LIMITED_API) -# include -# if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) -#define Py_LIMITED_API +# ifdef _MSC_VER +#if !defined(_DEBUG) && !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) +# define Py_LIMITED_API +#endif +#include + /* sanity-check: Py_LIMITED_API will cause crashes if any of these +are also defined. Normally, the Python file PC/pyconfig.h does not +cause any of these to be defined, with the exception that _DEBUG +causes Py_DEBUG. Double-check that. */ +#ifdef Py_LIMITED_API +# if defined(Py_DEBUG) +#error "pyconfig.h unexpectedly defines Py_DEBUG, but Py_LIMITED_API is set" +# endif +# if defined(Py_TRACE_REFS) +#error "pyconfig.h unexpectedly defines Py_TRACE_REFS, but Py_LIMITED_API is set" +# endif +# if defined(Py_REF_DEBUG) +#error "pyconfig.h unexpectedly defines Py_REF_DEBUG, but Py_LIMITED_API is set" +# endif +#endif +# else +#include +#if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) +# define Py_LIMITED_API +#endif # endif #endif 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 @@ -636,6 +636,10 @@ if isinstance(init, bytes): init = [init[i:i+1] for i in range(len(init))] else: +if isinstance(init, CTypesGenericArray): +if (len(init) != len(blob) or +not isinstance(init, CTypesArray)): +raise TypeError("length/type mismatch: %s" % (init,)) init = tuple(init) if len(init) > len(blob): raise IndexError("too many initializers") diff --git
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Ronan Lamy Branch: py3.6 Changeset: r94922:326720df4fbe Date: 2018-07-29 02:06 +0100 http://bitbucket.org/pypy/pypy/changeset/326720df4fbe/ Log:hg merge py3.5 diff --git a/pypy/interpreter/astcompiler/codegen.py b/pypy/interpreter/astcompiler/codegen.py --- a/pypy/interpreter/astcompiler/codegen.py +++ b/pypy/interpreter/astcompiler/codegen.py @@ -379,8 +379,8 @@ names) self._visit_arg_annotations(args.kwonlyargs, names) kwarg = args.kwarg -if args.kwarg: -self._visit_arg_annotation(args.kwarg.arg, args.kwarg.annotation, +if kwarg: +self._visit_arg_annotation(kwarg.arg, kwarg.annotation, names) self._visit_arg_annotation("return", returns, names) l = len(names) diff --git a/pypy/interpreter/astcompiler/symtable.py b/pypy/interpreter/astcompiler/symtable.py --- a/pypy/interpreter/astcompiler/symtable.py +++ b/pypy/interpreter/astcompiler/symtable.py @@ -640,6 +640,10 @@ assert isinstance(args, ast.arguments) if args.args: self._visit_arg_annotations(args.args) +if args.vararg: +self._visit_arg_annotation(args.vararg) +if args.kwarg: +self._visit_arg_annotation(args.kwarg) if args.kwonlyargs: self._visit_arg_annotations(args.kwonlyargs) if func.returns: @@ -648,8 +652,11 @@ def _visit_arg_annotations(self, args): for arg in args: assert isinstance(arg, ast.arg) -if arg.annotation: -arg.annotation.walkabout(self) +self._visit_arg_annotation(arg) + +def _visit_arg_annotation(self, arg): +if arg.annotation: +arg.annotation.walkabout(self) def visit_Name(self, name): if name.ctx == ast.Load: 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 @@ -470,7 +470,7 @@ def test_cmd_co_name(self): child = self.spawn(['-c', -'import sys; print sys._getframe(0).f_code.co_name']) +'import sys; print(sys._getframe(0).f_code.co_name)']) child.expect('') def test_ignore_python_inspect(self): diff --git a/pypy/interpreter/test/test_executioncontext.py b/pypy/interpreter/test/test_executioncontext.py --- a/pypy/interpreter/test/test_executioncontext.py +++ b/pypy/interpreter/test/test_executioncontext.py @@ -149,7 +149,7 @@ pass """) space.getexecutioncontext().setllprofile(None, None) -assert l == ['call', 'return', 'call', 'return'] +assert l[-4:] == ['call', 'return', 'call', 'return'] def test_llprofile_c_call(self): from pypy.interpreter.function import Function, Method @@ -173,15 +173,15 @@ return """ % snippet) space.getexecutioncontext().setllprofile(None, None) -assert l == ['call', 'return', 'call', 'c_call', 'c_return', 'return'] -if isinstance(seen[0], Method): -w_class = space.type(seen[0].w_instance) +assert l[-6:] == ['call', 'return', 'call', 'c_call', 'c_return', 'return'] +if isinstance(seen[-1], Method): +w_class = space.type(seen[-1].w_instance) found = 'method %s of %s' % ( -seen[0].w_function.name, +seen[-1].w_function.name, w_class.getname(space).encode('utf-8')) else: -assert isinstance(seen[0], Function) -found = 'builtin %s' % seen[0].name +assert isinstance(seen[-1], Function) +found = 'builtin %s' % seen[-1].name assert found == expected_c_call check_snippet('l = []; l.append(42)', 'method append of list') @@ -210,7 +210,7 @@ return """ % snippet) space.getexecutioncontext().setllprofile(None, None) -assert l == ['call', 'return', 'call', 'c_call', 'c_exception', 'return'] +assert l[-6:] == ['call', 'return', 'call', 'c_call', 'c_exception', 'return'] check_snippet('d = {}; d.__getitem__(42)') 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 @@ -153,6 +153,8 @@ r""" seen = [] def tracer(f, event, *args): +if f.f_code.co_name == "decode": +return tracer seen.append((event, f.f_lineno)) if len(seen) == 5: f.f_lineno = 1 # bug shown only when setting lineno to 1 @@ -297,7 +299,8 @@ l = [] def trace(a,b,c): -l.append((a,b,c)) +
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Ronan Lamy Branch: py3.6 Changeset: r94909:ebe135031f7e Date: 2018-07-28 02:00 +0100 http://bitbucket.org/pypy/pypy/changeset/ebe135031f7e/ Log:hg merge py3.5 diff too long, truncating to 2000 out of 4128 lines diff --git a/lib-python/3/fractions.py b/lib-python/3/fractions.py --- a/lib-python/3/fractions.py +++ b/lib-python/3/fractions.py @@ -542,7 +542,7 @@ else: return Fraction(round(self / shift) * shift) -def __hash__(self): +def __hash__(self, CACHE=[-1] * 1001): """hash(self)""" # XXX since this method is expensive, consider caching the result @@ -556,12 +556,23 @@ # dinv is the inverse of self._denominator modulo the prime # _PyHASH_MODULUS, or 0 if self._denominator is divisible by # _PyHASH_MODULUS. -dinv = pow(self._denominator, _PyHASH_MODULUS - 2, _PyHASH_MODULUS) + +# PyPy3: added caching of pow() results for denominators up to 1000 +denom = self._denominator +assert denom >= 0 +if denom < len(CACHE): +dinv = CACHE[denom] +if dinv == -1: +dinv = pow(denom, _PyHASH_MODULUS - 2, _PyHASH_MODULUS) +CACHE[denom] = dinv +else: +dinv = pow(denom, _PyHASH_MODULUS - 2, _PyHASH_MODULUS) + if not dinv: hash_ = _PyHASH_INF else: hash_ = abs(self._numerator) * dinv % _PyHASH_MODULUS -result = hash_ if self >= 0 else -hash_ +result = hash_ if self._numerator >= 0 else -hash_ return -2 if result == -1 else result def __eq__(a, b): diff --git a/lib-python/3/hashlib.py b/lib-python/3/hashlib.py --- a/lib-python/3/hashlib.py +++ b/lib-python/3/hashlib.py @@ -162,9 +162,14 @@ __get_hash = __get_openssl_constructor algorithms_available = algorithms_available.union( _hashlib.openssl_md_meth_names) -except ImportError: +except ImportError as e: new = __py_new __get_hash = __get_builtin_constructor +# added by PyPy +import warnings +warnings.warn("The _hashlib module is not available, falling back " + "to a much slower implementation (%s)" % str(e), + RuntimeWarning) try: # OpenSSL's PKCS5_PBKDF2_HMAC requires OpenSSL 1.0+ with HMAC and SHA diff --git a/lib_pypy/_winapi.py b/lib_pypy/_winapi.py --- a/lib_pypy/_winapi.py +++ b/lib_pypy/_winapi.py @@ -98,9 +98,11 @@ def GetOverlappedResult(self, wait): transferred = _ffi.new('DWORD[1]', [0]) res = _kernel32.GetOverlappedResult(self.handle, self.overlapped, transferred, wait != 0) -if not res: -res = GetLastError() -if res in (ERROR_SUCCESS, ERROR_MORE_DATA, ERROR_OPERATION_ABORTED): +if res: +err = ERROR_SUCCESS +else: +err = GetLastError() +if err in (ERROR_SUCCESS, ERROR_MORE_DATA, ERROR_OPERATION_ABORTED): self.completed = 1 self.pending = 0 elif res == ERROR_IO_INCOMPLETE: @@ -133,7 +135,7 @@ assert success == 0 err = _kernel32.GetLastError() if err == ERROR_IO_PENDING: -overlapped[0].pending = 1 +ov.pending = 1 elif err == ERROR_PIPE_CONNECTED: _kernel32.SetEvent(ov.overlapped[0].hEvent) else: diff --git a/lib_pypy/cffi.egg-info/PKG-INFO b/lib_pypy/cffi.egg-info/PKG-INFO --- a/lib_pypy/cffi.egg-info/PKG-INFO +++ b/lib_pypy/cffi.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: cffi -Version: 1.11.5 +Version: 1.12.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 from .error import CDefError, FFIError, VerificationError, VerificationMissing -__version__ = "1.11.5" -__version_info__ = (1, 11, 5) +__version__ = "1.12.0" +__version_info__ = (1, 12, 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/_embedding.h b/lib_pypy/cffi/_embedding.h --- a/lib_pypy/cffi/_embedding.h +++ b/lib_pypy/cffi/_embedding.h @@ -221,7 +221,7 @@ if (f != NULL && f != Py_None) { PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME - "\ncompiled with cffi version: 1.11.5" + "\ncompiled with cffi version: 1.12.0" "\n_cffi_backend module: ", f); modules = PyImport_GetModuleDict(); mod = PyDict_GetItemString(modules, "_cffi_backend"); 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 @@ -96,18 +96,21 @@
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Ronan LamyBranch: py3.6 Changeset: r94399:d1a46c216644 Date: 2018-04-20 23:47 +0100 http://bitbucket.org/pypy/pypy/changeset/d1a46c216644/ Log:hg merge py3.5 diff --git a/pypy/doc/release-v6.0.0.rst b/pypy/doc/release-v6.0.0.rst --- a/pypy/doc/release-v6.0.0.rst +++ b/pypy/doc/release-v6.0.0.rst @@ -18,6 +18,8 @@ getting started writing code. We have improved our parser to emit more friendly `syntax errors`_, making PyPy not only faster but more friendly. +The GC now has `hooks`_ to gain more insights into its performance + The Windows PyPy3.5 release is still considered beta-quality. There are open issues with unicode handling especially around system calls and c-extensions. @@ -53,6 +55,7 @@ .. _`blog post`: https://morepypy.blogspot.it/2017/10/cape-of-good-hope-for-pypy-hello-from.html .. _pygobject: https://lazka.github.io/posts/2018-04_pypy-pygobject/index.html .. _`syntax errors`: https://morepypy.blogspot.com/2018/04/improving-syntaxerror-in-pypy.html +.. _`hooks`: gc_info.html#gc-hooks What is PyPy? = @@ -101,8 +104,9 @@ * Added missing attributes to C-API ``instancemethod`` on pypy3 * Store error state in thread-local storage for C-API. * Fix JIT bugs exposed in the sre module -* Improve speed of Python parser, improve ParseError messages slightly +* Improve speed of Python parser, improve ParseError messages and SyntaxError * Handle JIT hooks more efficiently +* Fix a rare GC bug exposed by intensive use of cpyext `Buffer` s We also refactored many parts of the JIT bridge optimizations, as well as cpyext internals, and together with new contributors fixed issues, added new diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -3,18 +3,7 @@ == .. this is a revision shortly after release-pypy-6.0.0 -.. startrev: f22145c34985 +.. startrev: ad79cc0ce9a8 -.. branch: issue2752 -Fix a rare GC bug that was introduced more than one year ago, but was -not diagnosed before issue #2752. - -.. branch: gc-hooks - -Introduce GC hooks, as documented in doc/gc_info.rst - -.. branch: gc-hook-better-timestamp - -Improve GC hooks diff --git a/pypy/doc/whatsnew-pypy2-6.0.0.rst b/pypy/doc/whatsnew-pypy2-6.0.0.rst --- a/pypy/doc/whatsnew-pypy2-6.0.0.rst +++ b/pypy/doc/whatsnew-pypy2-6.0.0.rst @@ -113,3 +113,16 @@ Improve line offsets that are reported by SyntaxError. Improve error messages for a few situations, including mismatched parenthesis. + +.. branch: issue2752 + +Fix a rare GC bug that was introduced more than one year ago, but was +not diagnosed before issue #2752. + +.. branch: gc-hooks + +Introduce GC hooks, as documented in doc/gc_info.rst + +.. branch: gc-hook-better-timestamp + +Improve GC hooksd 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 @@ -3,5 +3,5 @@ .. this is the revision after release-pypy3.5-v6.0 -.. startrev: bf74662ee4fa +.. startrev: 580e3e26cd32 diff --git a/pypy/module/__pypy__/interp_pypydatetime.py b/pypy/module/__pypy__/interp_pypydatetime.py --- a/pypy/module/__pypy__/interp_pypydatetime.py +++ b/pypy/module/__pypy__/interp_pypydatetime.py @@ -5,7 +5,7 @@ def create_class(name): class W_Class(W_Root): -'builtin base clasee for datetime.%s to allow interop with cpyext' % name +'builtin base class for datetime.%s to allow interop with cpyext' % name def descr_new__(space, w_type): return space.allocate_instance(W_Class, w_type) diff --git a/pypy/module/cpyext/cdatetime.py b/pypy/module/cpyext/cdatetime.py --- a/pypy/module/cpyext/cdatetime.py +++ b/pypy/module/cpyext/cdatetime.py @@ -40,18 +40,26 @@ w_type = space.getattr(w_datetime, space.newtext("datetime")) datetimeAPI.c_DateTimeType = rffi.cast( PyTypeObjectPtr, make_ref(space, w_type)) +datetimeAPI.c_DateTimeType.c_tp_basicsize = rffi.sizeof( +cts.gettype('PyDateTime_DateTime')) w_type = space.getattr(w_datetime, space.newtext("time")) datetimeAPI.c_TimeType = rffi.cast( PyTypeObjectPtr, make_ref(space, w_type)) +datetimeAPI.c_TimeType.c_tp_basicsize = rffi.sizeof( +cts.gettype('PyDateTime_Time')) w_type = space.getattr(w_datetime, space.newtext("timedelta")) datetimeAPI.c_DeltaType = rffi.cast( PyTypeObjectPtr, make_ref(space, w_type)) +datetimeAPI.c_DeltaType.c_tp_basicsize = rffi.sizeof( +cts.gettype('PyDateTime_Delta')) w_type = space.getattr(w_datetime, space.newtext("tzinfo")) datetimeAPI.c_TZInfoType = rffi.cast( PyTypeObjectPtr, make_ref(space, w_type)) +datetimeAPI.c_TZInfoType.c_tp_basicsize = rffi.sizeof( +cts.gettype('PyDateTime_TZInfo')) datetimeAPI.c_Date_FromDate = llhelper(
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Manuel JacobBranch: py3.6 Changeset: r94018:845ecbcca6b6 Date: 2018-03-19 23:22 +0100 http://bitbucket.org/pypy/pypy/changeset/845ecbcca6b6/ Log:hg merge py3.5 diff --git a/lib-python/3/distutils/msvc9compiler.py b/lib-python/3/distutils/msvc9compiler.py --- a/lib-python/3/distutils/msvc9compiler.py +++ b/lib-python/3/distutils/msvc9compiler.py @@ -243,7 +243,7 @@ productdir = os.path.join(toolsdir, os.pardir, os.pardir, "VC") productdir = os.path.abspath(productdir) if not os.path.isdir(productdir): - + log.debug("%s is not a valid directory" % productdir) return None else: diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -15,6 +15,7 @@ from rpython.rlib.listsort import make_timsort_class from rpython.rlib.objectmodel import ( import_from_mixin, instantiate, newlist_hint, resizelist_hint, specialize) +from rpython.rlib.rarithmetic import ovfcheck from rpython.rlib import longlong2float from rpython.tool.sourcetools import func_with_new_name @@ -848,7 +849,12 @@ """Extend w_list from a generic iterable""" length_hint = self.space.length_hint(w_iterable, 0) if length_hint: -w_list._resize_hint(w_list.length() + length_hint) +try: +newsize_hint = ovfcheck(w_list.length() + length_hint) +except OverflowError: +pass +else: +w_list._resize_hint(newsize_hint) extended = _do_extend_from_iterable(self.space, w_list, w_iterable) diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py --- a/pypy/objspace/std/test/test_listobject.py +++ b/pypy/objspace/std/test/test_listobject.py @@ -618,6 +618,18 @@ assert l == [1.2, 2.3, 3.4, 4.5] assert l is l0 +def test_extend_iterable_length_hint_overflow(self): +import sys +class CustomIterable(object): +def __iter__(self): +if False: +yield +def __length_hint__(self): +return sys.maxsize +a = [1, 2, 3, 4] +a.extend(CustomIterable()) +assert a == [1, 2, 3, 4] + def test_sort(self): l = l0 = [1, 5, 3, 0] l.sort() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Manuel JacobBranch: py3.6 Changeset: r94007:a756aa082d6b Date: 2018-03-19 17:14 +0100 http://bitbucket.org/pypy/pypy/changeset/a756aa082d6b/ Log:hg merge py3.5 diff too long, truncating to 2000 out of 2599 lines diff --git a/lib-python/3/distutils/msvc9compiler.py b/lib-python/3/distutils/msvc9compiler.py --- a/lib-python/3/distutils/msvc9compiler.py +++ b/lib-python/3/distutils/msvc9compiler.py @@ -223,6 +223,7 @@ that fails it falls back to the VS90COMNTOOLS env var. """ vsbase = VS_BASE % version +batfile = 'vcvarsall.bat' try: productdir = Reg.get_value(r"%s\Setup\VC" % vsbase, "productdir") @@ -235,9 +236,14 @@ toolsdir = os.environ.get(toolskey, None) if toolsdir and os.path.isdir(toolsdir): -productdir = os.path.join(toolsdir, os.pardir, os.pardir, "VC") -productdir = os.path.abspath(productdir) +if os.path.exists(os.path.join(toolsdir, 'VsDevCmd.bat')): +productdir = toolsdir +batfile = 'VsDevCmd.bat' +else: +productdir = os.path.join(toolsdir, os.pardir, os.pardir, "VC") +productdir = os.path.abspath(productdir) if not os.path.isdir(productdir): + log.debug("%s is not a valid directory" % productdir) return None else: @@ -245,7 +251,7 @@ if not productdir: log.debug("No productdir found") return None -vcvarsall = os.path.join(productdir, "vcvarsall.bat") +vcvarsall = os.path.join(productdir, batfile) if os.path.isfile(vcvarsall): return vcvarsall log.debug("Unable to find vcvarsall.bat") @@ -289,6 +295,7 @@ if len(result) != len(interesting): raise ValueError(str(list(result.keys( +log.debug('Got', result) return result # More globals diff --git a/lib_pypy/_dbm.py b/lib_pypy/_dbm.py --- a/lib_pypy/_dbm.py +++ b/lib_pypy/_dbm.py @@ -168,7 +168,14 @@ def open(filename, flag='r', mode=0o666): "open a DBM database" if not isinstance(filename, str): -raise TypeError("expected string") +if sys.version_info < (3,) and isinstance(filename, unicode): +# unlike CPython we'll encode 'filename' with filesystemencoding +# instead of defaultencoding, because that seems like a far +# better idea. But I'm also open for saying that we should +# rather go for bug-to-bug compatibility instead. +filename = filename.encode(sys.getfilesystemencoding()) +else: +raise TypeError("expected string") filename = filename.encode(sys.getdefaultencoding()) openflag = 0 diff --git a/lib_pypy/_pypy_testcapi.py b/lib_pypy/_pypy_testcapi.py --- a/lib_pypy/_pypy_testcapi.py +++ b/lib_pypy/_pypy_testcapi.py @@ -3,7 +3,7 @@ import importlib.machinery -def get_hashed_dir(cfile): +def _get_hashed_filename(cfile): with open(cfile,'r') as fid: content = fid.read() # from cffi's Verifier() @@ -23,10 +23,28 @@ username = os.environ['USERNAME'] #windows except KeyError: username = os.getuid() -output_dir = tempfile.gettempdir() + os.path.sep + 'tmp_%s_%s%s' % ( +return tempfile.gettempdir() + os.path.sep + 'testcapi_%s_%s%s' % ( username, k1, k2) -if not os.path.exists(output_dir): + +def get_hashed_dir(cfile): +hashed_fn = _get_hashed_filename(cfile) +try: +with open(hashed_fn) as f: +dirname = f.read(1024) +except IOError: +dirname = '' +tmpdir = tempfile.gettempdir() +if (not dirname or '/' in dirname or '\\' in dirname or '\x00' in dirname +or not os.path.isdir(os.path.join(tmpdir, dirname))): +dirname = binascii.hexlify(os.urandom(8)) +if not isinstance(dirname, str):# Python 3 +dirname = dirname.decode('ascii') +dirname = 'testcapi_' + dirname +output_dir = os.path.join(tmpdir, dirname) +try: os.mkdir(output_dir) +except OSError: +pass return output_dir @@ -35,13 +53,12 @@ return suffixes[0] if suffixes else None -def compile_shared(csource, modulename, output_dir=None): +def compile_shared(csource, modulename, output_dir): """Compile '_testcapi.c' or '_ctypes_test.c' into an extension module, and import it. """ thisdir = os.path.dirname(__file__) -if output_dir is None: -output_dir = tempfile.mkdtemp() +assert output_dir is not None from distutils.ccompiler import new_compiler @@ -85,4 +102,16 @@ # Now import the newly created library, it will replace the original # module in sys.modules fp, filename, description = imp.find_module(modulename, path=[output_dir]) -imp.load_module(modulename, fp, filename, description) +with fp: +
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Amaury Forgeot d'ArcBranch: py3.6 Changeset: r93931:eb5abc38e4b2 Date: 2018-02-25 23:09 +0100 http://bitbucket.org/pypy/pypy/changeset/eb5abc38e4b2/ Log:hg merge py3.5 diff too long, truncating to 2000 out of 5407 lines diff --git a/extra_tests/test_pyrepl/__init__.py b/extra_tests/test_pyrepl/__init__.py new file mode 100644 --- /dev/null +++ b/extra_tests/test_pyrepl/__init__.py @@ -0,0 +1,1 @@ + diff --git a/extra_tests/test_pyrepl/infrastructure.py b/extra_tests/test_pyrepl/infrastructure.py new file mode 100644 --- /dev/null +++ b/extra_tests/test_pyrepl/infrastructure.py @@ -0,0 +1,87 @@ +# Copyright 2000-2004 Michael Hudson-Doyle +# +#All Rights Reserved +# +# +# Permission to use, copy, modify, and distribute this software and +# its documentation for any purpose is hereby granted without fee, +# provided that the above copyright notice appear in all copies and +# that both that copyright notice and this permission notice appear in +# supporting documentation. +# +# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO +# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, +# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER +# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF +# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +from __future__ import print_function +from contextlib import contextmanager +import os + +from pyrepl.reader import Reader +from pyrepl.console import Console, Event + + +class EqualsAnything(object): +def __eq__(self, other): +return True + + +EA = EqualsAnything() + + +class TestConsole(Console): +height = 24 +width = 80 +encoding = 'utf-8' + +def __init__(self, events, verbose=False): +self.events = events +self.next_screen = None +self.verbose = verbose + +def refresh(self, screen, xy): +if self.next_screen is not None: +assert screen == self.next_screen, "[ %s != %s after %r ]" % ( +screen, self.next_screen, self.last_event_name) + +def get_event(self, block=1): +ev, sc = self.events.pop(0) +self.next_screen = sc +if not isinstance(ev, tuple): +ev = (ev, None) +self.last_event_name = ev[0] +if self.verbose: +print("event", ev) +return Event(*ev) + + +class BaseTestReader(Reader): + +def get_prompt(self, lineno, cursor_on_line): +return '' + +def refresh(self): +Reader.refresh(self) +self.dirty = True + + +def read_spec(test_spec, reader_class=BaseTestReader): +# remember to finish your test_spec with 'accept' or similar! +con = TestConsole(test_spec, verbose=True) +reader = reader_class(con) +reader.readline() + + +@contextmanager +def sane_term(): +"""Ensure a TERM that supports clear""" +old_term, os.environ['TERM'] = os.environ.get('TERM'), 'xterm' +yield +if old_term is not None: +os.environ['TERM'] = old_term +else: +del os.environ['TERM'] diff --git a/extra_tests/test_pyrepl/test_basic.py b/extra_tests/test_pyrepl/test_basic.py new file mode 100644 --- /dev/null +++ b/extra_tests/test_pyrepl/test_basic.py @@ -0,0 +1,116 @@ +# Copyright 2000-2004 Michael Hudson-Doyle +# +#All Rights Reserved +# +# +# Permission to use, copy, modify, and distribute this software and +# its documentation for any purpose is hereby granted without fee, +# provided that the above copyright notice appear in all copies and +# that both that copyright notice and this permission notice appear in +# supporting documentation. +# +# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO +# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, +# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER +# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF +# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +import pytest +from .infrastructure import read_spec + + +def test_basic(): +read_spec([(('self-insert', 'a'), ['a']), + ( 'accept',['a'])]) + + +def test_repeat(): +read_spec([(('digit-arg', '3'), ['']), + (('self-insert', 'a'), ['aaa']), + ( 'accept',['aaa'])]) + + +def test_kill_line(): +read_spec([(('self-insert', 'abc'), ['abc']), + ( 'left',None), + ( 'kill-line', ['ab']), + ( 'accept', ['ab'])]) + + +def test_unix_line_discard(): +
[pypy-commit] pypy py3.6: hg merge py3.5 (+ fixes)
Author: Manuel JacobBranch: py3.6 Changeset: r93320:f04d4604c7e3 Date: 2017-12-09 03:14 +0100 http://bitbucket.org/pypy/pypy/changeset/f04d4604c7e3/ Log:hg merge py3.5 (+ fixes) I'm not 100% sure about the merge in test_dis.py, but most of the tests are failing anyway. diff too long, truncating to 2000 out of 12565 lines diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -59,6 +59,7 @@ ^rpython/rlib/rvmprof/src/shared/libbacktrace/config.h$ ^rpython/rlib/rvmprof/src/shared/libbacktrace/config.log$ ^rpython/rlib/rvmprof/src/shared/libbacktrace/config.status$ +^pypy/tool/dest$ ^pypy/goal/pypy-translation-snapshot$ ^pypy/goal/pypy-c ^pypy/goal/pypy3-c diff --git a/_pytest/terminal.py b/_pytest/terminal.py --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -366,11 +366,11 @@ EXIT_OK, EXIT_TESTSFAILED, EXIT_INTERRUPTED, EXIT_USAGEERROR, EXIT_NOTESTSCOLLECTED) if exitstatus in summary_exit_codes: -self.config.hook.pytest_terminal_summary(terminalreporter=self) self.summary_errors() self.summary_failures() self.summary_warnings() self.summary_passes() +self.config.hook.pytest_terminal_summary(terminalreporter=self) if exitstatus == EXIT_INTERRUPTED: self._report_keyboardinterrupt() del self._keyboardinterrupt_memo diff --git a/extra_tests/requirements.txt b/extra_tests/requirements.txt new file mode 100644 --- /dev/null +++ b/extra_tests/requirements.txt @@ -0,0 +1,2 @@ +pytest +hypothesis diff --git a/extra_tests/test_bytes.py b/extra_tests/test_bytes.py new file mode 100644 --- /dev/null +++ b/extra_tests/test_bytes.py @@ -0,0 +1,84 @@ +from hypothesis import strategies as st +from hypothesis import given, example + +st_bytestring = st.binary() | st.binary().map(bytearray) + +@given(st_bytestring, st_bytestring, st_bytestring) +def test_find(u, prefix, suffix): +s = prefix + u + suffix +assert 0 <= s.find(u) <= len(prefix) +assert s.find(u, len(prefix), len(s) - len(suffix)) == len(prefix) + +@given(st_bytestring, st_bytestring, st_bytestring) +def test_index(u, prefix, suffix): +s = prefix + u + suffix +assert 0 <= s.index(u) <= len(prefix) +assert s.index(u, len(prefix), len(s) - len(suffix)) == len(prefix) + +@given(st_bytestring, st_bytestring, st_bytestring) +def test_rfind(u, prefix, suffix): +s = prefix + u + suffix +assert s.rfind(u) >= len(prefix) +assert s.rfind(u, len(prefix), len(s) - len(suffix)) == len(prefix) + +@given(st_bytestring, st_bytestring, st_bytestring) +def test_rindex(u, prefix, suffix): +s = prefix + u + suffix +assert s.rindex(u) >= len(prefix) +assert s.rindex(u, len(prefix), len(s) - len(suffix)) == len(prefix) + +def adjust_indices(u, start, end): +if end < 0: +end = max(end + len(u), 0) +else: +end = min(end, len(u)) +if start < 0: +start = max(start + len(u), 0) +return start, end + +@given(st_bytestring, st_bytestring) +def test_startswith_basic(u, v): +assert u.startswith(v) is (u[:len(v)] == v) + +@example(b'x', b'', 1) +@example(b'x', b'', 2) +@given(st_bytestring, st_bytestring, st.integers()) +def test_startswith_start(u, v, start): +expected = u[start:].startswith(v) if v else (start <= len(u)) +assert u.startswith(v, start) is expected + +@example(b'x', b'', 1, 0) +@example(b'xx', b'', -1, 0) +@given(st_bytestring, st_bytestring, st.integers(), st.integers()) +def test_startswith_3(u, v, start, end): +if v: +expected = u[start:end].startswith(v) +else: # CPython leaks implementation details in this case +start0, end0 = adjust_indices(u, start, end) +expected = start0 <= len(u) and start0 <= end0 +assert u.startswith(v, start, end) is expected + +@given(st_bytestring, st_bytestring) +def test_endswith_basic(u, v): +if len(v) > len(u): +assert u.endswith(v) is False +else: +assert u.endswith(v) is (u[len(u) - len(v):] == v) + +@example(b'x', b'', 1) +@example(b'x', b'', 2) +@given(st_bytestring, st_bytestring, st.integers()) +def test_endswith_2(u, v, start): +expected = u[start:].endswith(v) if v else (start <= len(u)) +assert u.endswith(v, start) is expected + +@example(b'x', b'', 1, 0) +@example(b'xx', b'', -1, 0) +@given(st_bytestring, st_bytestring, st.integers(), st.integers()) +def test_endswith_3(u, v, start, end): +if v: +expected = u[start:end].endswith(v) +else: # CPython leaks implementation details in this case +start0, end0 = adjust_indices(u, start, end) +expected = start0 <= len(u) and start0 <= end0 +assert u.endswith(v, start, end) is expected diff --git a/extra_tests/test_textio.py b/extra_tests/test_textio.py new file mode 100644 --- /dev/null +++ b/extra_tests/test_textio.py @@ -0,0 +1,48 @@ +from hypothesis import given,
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Ronan LamyBranch: py3.6 Changeset: r92878:40e3c2a486e9 Date: 2017-10-30 01:18 + http://bitbucket.org/pypy/pypy/changeset/40e3c2a486e9/ Log:hg merge py3.5 diff too long, truncating to 2000 out of 11351 lines diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -75,6 +75,8 @@ ^lib_pypy/.+.c$ ^lib_pypy/.+.o$ ^lib_pypy/.+.so$ +^lib_pypy/.+.pyd$ +^lib_pypy/Release/ ^pypy/doc/discussion/.+\.html$ ^include/.+\.h$ ^include/.+\.inl$ diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -40,3 +40,7 @@ 2875f328eae2216a87f3d6f335092832eb031f56 release-pypy3.5-v5.7.1 c925e73810367cd960a32592dd7f728f436c125c release-pypy2.7-v5.8.0 a37ecfe5f142bc971a86d17305cc5d1d70abec64 release-pypy3.5-v5.8.0 +03d614975835870da65ff0481e1edad68ebbcb8d release-pypy2.7-v5.9.0 +d72f9800a42b46a8056951b1da2426d2c2d8d502 release-pypy3.5-v5.9.0 +03d614975835870da65ff0481e1edad68ebbcb8d release-pypy2.7-v5.9.0 +84a2f3e6a7f88f2fe698e473998755b3bd1a12e2 release-pypy2.7-v5.9.0 diff --git a/lib-python/3/ctypes/test/test_bitfields.py b/lib-python/3/ctypes/test/test_bitfields.py --- a/lib-python/3/ctypes/test/test_bitfields.py +++ b/lib-python/3/ctypes/test/test_bitfields.py @@ -1,5 +1,5 @@ from ctypes import * -from ctypes.test import need_symbol +from ctypes.test import need_symbol, xfail import unittest import os @@ -278,6 +278,7 @@ self.assertEqual(b, b'\xef\xcd\xab\x21') @need_symbol('c_uint32') +@xfail def test_uint32_swap_big_endian(self): # Issue #23319 class Big(BigEndianStructure): diff --git a/lib-python/3/ctypes/test/test_byteswap.py b/lib-python/3/ctypes/test/test_byteswap.py --- a/lib-python/3/ctypes/test/test_byteswap.py +++ b/lib-python/3/ctypes/test/test_byteswap.py @@ -2,6 +2,7 @@ from binascii import hexlify from ctypes import * +from test.support import impl_detail def bin(s): return hexlify(memoryview(s)).decode().upper() @@ -22,6 +23,7 @@ setattr(bits, "i%s" % i, 1) dump(bits) +@impl_detail("slots are irrelevant on PyPy", pypy=False) def test_slots(self): class BigPoint(BigEndianStructure): __slots__ = () diff --git a/lib-python/3/ctypes/test/test_frombuffer.py b/lib-python/3/ctypes/test/test_frombuffer.py --- a/lib-python/3/ctypes/test/test_frombuffer.py +++ b/lib-python/3/ctypes/test/test_frombuffer.py @@ -85,7 +85,6 @@ del a gc.collect() # Should not crash -@xfail def test_from_buffer_copy(self): a = array.array("i", range(16)) x = (c_int * 16).from_buffer_copy(a) diff --git a/lib-python/3/ctypes/test/test_values.py b/lib-python/3/ctypes/test/test_values.py --- a/lib-python/3/ctypes/test/test_values.py +++ b/lib-python/3/ctypes/test/test_values.py @@ -4,6 +4,7 @@ import unittest import sys +from test.support import cpython_only from ctypes import * import _ctypes_test @@ -28,6 +29,7 @@ ctdll = CDLL(_ctypes_test.__file__) self.assertRaises(ValueError, c_int.in_dll, ctdll, "Undefined_Symbol") +@cpython_only class PythonValuesTestCase(unittest.TestCase): """This test only works when python itself is a dll/shared library""" diff --git a/lib-python/3/test/test_bytes.py b/lib-python/3/test/test_bytes.py --- a/lib-python/3/test/test_bytes.py +++ b/lib-python/3/test/test_bytes.py @@ -780,7 +780,6 @@ self.assertIs(type(BytesSubclass(A())), BytesSubclass) # Test PyBytes_FromFormat() -@test.support.impl_detail("don't test cpyext here") def test_from_format(self): ctypes = test.support.import_module('ctypes') _testcapi = test.support.import_module('_testcapi') diff --git a/lib-python/3/test/test_unicode.py b/lib-python/3/test/test_unicode.py --- a/lib-python/3/test/test_unicode.py +++ b/lib-python/3/test/test_unicode.py @@ -2436,6 +2436,10 @@ # Test PyUnicode_FromFormat() def test_from_format(self): support.import_module('ctypes') +try: +from ctypes import pythonapi +except ImportError: +self.skipTest( "no pythonapi in ctypes") from ctypes import ( pythonapi, py_object, sizeof, c_int, c_long, c_longlong, c_ssize_t, diff --git a/lib_pypy/_ctypes/array.py b/lib_pypy/_ctypes/array.py --- a/lib_pypy/_ctypes/array.py +++ b/lib_pypy/_ctypes/array.py @@ -8,9 +8,14 @@ class ArrayMeta(_CDataMeta): def __new__(self, name, cls, typedict): res = type.__new__(self, name, cls, typedict) + if cls == (_CData,): # this is the Array class defined below +res._ffiarray = None return res - +if not hasattr(res, '_length_') or not isinstance(res._length_, int): +raise AttributeError( +"class must define a '_length_' attribute, " +"which must be a positive integer") ffiarray = res._ffiarray = _rawffi.Array(res._type_._ffishape_)
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Manuel JacobBranch: py3.6 Changeset: r92514:d4a38e82d0d7 Date: 2017-09-29 19:50 +0200 http://bitbucket.org/pypy/pypy/changeset/d4a38e82d0d7/ Log:hg merge py3.5 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 @@ -669,7 +669,7 @@ 'PySlice_Type': 'space.gettypeobject(W_SliceObject.typedef)', 'PyStaticMethod_Type': 'space.gettypeobject(StaticMethod.typedef)', 'PyCFunction_Type': 'space.gettypeobject(cpyext.methodobject.W_PyCFunctionObject.typedef)', -'PyWrapperDescr_Type': 'space.gettypeobject(cpyext.methodobject.W_PyCMethodObject.typedef)', +'PyWrapperDescr_Type': 'space.gettypeobject(cpyext.methodobject.W_PyCWrapperObject.typedef)', 'PyInstanceMethod_Type': 'space.gettypeobject(cpyext.classobject.InstanceMethod.typedef)', }.items(): register_global(cpyname, 'PyTypeObject*', pypyexpr, header=pypy_decl) @@ -1338,17 +1338,20 @@ for decl in FORWARD_DECLS: decls[pypy_decl].append("%s;" % (decl,)) decls[pypy_decl].append(""" -/* hack for https://bugs.python.org/issue29943 */ -PyAPI_FUNC(int) %s(PySliceObject *arg0, - Signed arg1, Signed *arg2, - Signed *arg3, Signed *arg4, Signed *arg5); -static int PySlice_GetIndicesEx(PySliceObject *arg0, Py_ssize_t arg1, -Py_ssize_t *arg2, Py_ssize_t *arg3, Py_ssize_t *arg4, -Py_ssize_t *arg5) { -return %s(arg0, arg1, arg2, arg3, - arg4, arg5); -} -""" % ((mangle_name(prefix, 'PySlice_GetIndicesEx'),)*2)) +/* hack for https://bugs.python.org/issue29943 */ + +PyAPI_FUNC(int) %s(PyObject *arg0, +Signed arg1, Signed *arg2, +Signed *arg3, Signed *arg4, Signed *arg5); +#ifdef __GNUC__ +__attribute__((__unused__)) +#endif +static int PySlice_GetIndicesEx(PyObject *arg0, Py_ssize_t arg1, +Py_ssize_t *arg2, Py_ssize_t *arg3, Py_ssize_t *arg4, +Py_ssize_t *arg5) { +return %s(arg0, arg1, arg2, arg3, +arg4, arg5); +}""" % ((mangle_name(prefix, 'PySlice_GetIndicesEx'),)*2)) for header_name, header_functions in FUNCTIONS_BY_HEADER.iteritems(): header = decls[header_name] diff --git a/pypy/module/cpyext/include/descrobject.h b/pypy/module/cpyext/include/descrobject.h --- a/pypy/module/cpyext/include/descrobject.h +++ b/pypy/module/cpyext/include/descrobject.h @@ -1,34 +1,6 @@ #ifndef Py_DESCROBJECT_H #define Py_DESCROBJECT_H -#define PyDescr_COMMON \ -PyObject_HEAD \ -PyTypeObject *d_type; \ -PyObject *d_name - -typedef struct { -PyDescr_COMMON; -} PyDescrObject; - -typedef struct { -PyDescr_COMMON; -PyMethodDef *d_method; -} PyMethodDescrObject; - -typedef struct { -PyDescr_COMMON; -struct PyMemberDef *d_member; -} PyMemberDescrObject; - -typedef struct { -PyDescr_COMMON; -PyGetSetDef *d_getset; -} PyGetSetDescrObject; - -typedef struct { -PyDescr_COMMON; -struct wrapperbase *d_base; -void *d_wrapped; /* This can be any function pointer */ -} PyWrapperDescrObject; +#include "cpyext_descrobject.h" #endif diff --git a/pypy/module/cpyext/methodobject.py b/pypy/module/cpyext/methodobject.py --- a/pypy/module/cpyext/methodobject.py +++ b/pypy/module/cpyext/methodobject.py @@ -1,4 +1,4 @@ -from rpython.rtyper.lltypesystem import lltype, rffi, llmemory +from rpython.rtyper.lltypesystem import lltype, rffi from pypy.interpreter.baseobjspace import W_Root from pypy.interpreter.error import OperationError, oefmt @@ -10,8 +10,8 @@ from pypy.module.cpyext.api import ( CONST_STRING, METH_CLASS, METH_COEXIST, METH_KEYWORDS, METH_NOARGS, METH_O, METH_STATIC, METH_VARARGS, PyObject, bootstrap_function, -cpython_api, generic_cpy_call, CANNOT_FAIL, -PyTypeObjectPtr, slot_function, cts) +cpython_api, generic_cpy_call, CANNOT_FAIL, slot_function, cts, +build_type_checkers) from pypy.module.cpyext.pyobject import ( Py_DecRef, from_ref, make_ref, as_pyobj, make_typedescr) @@ -102,7 +102,7 @@ return self.space.unwrap(self.descr_method_repr()) def descr_method_repr(self): -w_objclass = self.w_objclass +w_objclass = self.w_objclass assert isinstance(w_objclass, W_TypeObject) return self.space.newtext("" % ( self.name, w_objclass.name)) @@ -110,7 +110,7 @@ def descr_call(self, space, __args__): args_w, kw_w = __args__.unpack() if len(args_w) < 1: -w_objclass = self.w_objclass +w_objclass = self.w_objclass assert isinstance(w_objclass, W_TypeObject) raise oefmt(space.w_TypeError, "descriptor '%8' of '%s' object needs an argument", @@ -118,7 +118,7 @@ w_instance = args_w[0] # XXX: needs a stricter
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Manuel JacobBranch: py3.6 Changeset: r92492:2a061e98f19f Date: 2017-09-28 22:24 +0200 http://bitbucket.org/pypy/pypy/changeset/2a061e98f19f/ Log:hg merge py3.5 diff too long, truncating to 2000 out of 33754 lines diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -27,16 +27,17 @@ ^pypy/module/cpyext/test/.+\.manifest$ ^pypy/module/test_lib_pypy/ctypes_tests/.+\.o$ ^pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test\.o$ -^pypy/module/cppyy/src/.+\.o$ -^pypy/module/cppyy/bench/.+\.so$ -^pypy/module/cppyy/bench/.+\.root$ -^pypy/module/cppyy/bench/.+\.d$ -^pypy/module/cppyy/src/.+\.errors$ -^pypy/module/cppyy/test/.+_rflx\.cpp$ -^pypy/module/cppyy/test/.+\.so$ -^pypy/module/cppyy/test/.+\.rootmap$ -^pypy/module/cppyy/test/.+\.exe$ -^pypy/module/cppyy/test/.+_cint.h$ +^pypy/module/_cppyy/src/.+\.o$ +^pypy/module/_cppyy/bench/.+\.so$ +^pypy/module/_cppyy/bench/.+\.root$ +^pypy/module/_cppyy/bench/.+\.d$ +^pypy/module/_cppyy/src/.+\.errors$ +^pypy/module/_cppyy/test/.+_rflx\.cpp$ +^pypy/module/_cppyy/test/.+\.so$ +^pypy/module/_cppyy/test/.+\.rootmap$ +^pypy/module/_cppyy/test/.+\.exe$ +^pypy/module/_cppyy/test/.+_cint.h$ +^pypy/module/_cppyy/.+/*\.pcm$ ^pypy/module/test_lib_pypy/cffi_tests/__pycache__.+$ ^pypy/doc/.+\.html$ ^pypy/doc/config/.+\.rst$ @@ -93,6 +94,3 @@ ^release/ ^rpython/_cache$ -pypy/module/cppyy/.+/*\.pcm - - diff --git a/LICENSE b/LICENSE --- a/LICENSE +++ b/LICENSE @@ -60,8 +60,8 @@ Wim Lavrijsen Eric van Riet Paap Richard Emslie + Remi Meier Alexander Schremmer - Remi Meier Dan Villiom Podlaski Christiansen Lukas Diekmann Sven Hager @@ -102,6 +102,7 @@ Michael Foord Stephan Diehl Stefano Rivera + Jean-Paul Calderone Stefan Schwarzer Tomek Meka Valentino Volonghi @@ -110,14 +111,13 @@ Bob Ippolito Bruno Gola David Malcolm - Jean-Paul Calderone Squeaky Edd Barrett Timo Paulssen Marius Gedminas + Nicolas Truessel Alexandre Fayolle Simon Burton - Nicolas Truessel Martin Matusiak Laurence Tratt Wenzhu Man @@ -156,6 +156,7 @@ Stefan H. Muller Tim Felgentreff Eugene Oden + Dodan Mihai Jeff Terrace Henry Mason Vasily Kuznetsov @@ -182,11 +183,13 @@ Rocco Moretti Gintautas Miliauskas Lucian Branescu Mihaila + Mariano Anaya anatoly techtonik - Dodan Mihai Karl Bartel + Stefan Beyer Gabriel Lavoie Jared Grubb + Alecsandru Patrascu Olivier Dormond Wouter van Heyst Sebastian Pawlu @@ -194,6 +197,7 @@ Victor Stinner Andrews Medina Aaron Iles + p_ziesch...@yahoo.de Toby Watson Daniel Patrick Stuart Williams @@ -204,6 +208,7 @@ Michael Cheng Mikael Schnenberg Stanislaw Halik + Mihnea Saracin Berkin Ilbeyi Gasper Zejn Faye Zhao @@ -214,14 +219,12 @@ Jonathan David Riehl Beatrice During Alex Perry - p_ziesch...@yahoo.de Robert Zaremba Alan McIntyre Alexander Sedov Vaibhav Sood Reuben Cummings Attila Gobi - Alecsandru Patrascu Christopher Pope Tristan Arthur Christian Tismer @@ -243,7 +246,6 @@ Jacek Generowicz Sylvain Thenault Jakub Stasiak - Stefan Beyer Andrew Dalke Alejandro J. Cura Vladimir Kryachko @@ -275,6 +277,7 @@ Christoph Gerum Miguel de Val Borro Artur Lisiecki + afteryu Toni Mattis Laurens Van Houtven Bobby Impollonia @@ -305,6 +308,7 @@ Anna Katrina Dominguez Kim Jin Su Amber Brown + Anthony Sottile Nate Bragg Ben Darnell Juan Francisco Cantero Hurtado @@ -325,12 +329,14 @@ Mike Bayer Rodrigo Arajo Daniil Yarancev + Min RK OlivierBlanvillain Jonas Pfannschmidt Zearin Andrey Churin Dan Crosta reub...@gmail.com + Stanisaw Halik Julien Phalip Roman Podoliaka Eli Stevens diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ RUNINTERP = $(PYPY_EXECUTABLE) endif -.PHONY: cffi_imports +.PHONY: pypy-c cffi_imports pypy-c: @echo @@ -32,7 +32,7 @@ @echo "" @echo @sleep 5 - $(RUNINTERP) rpython/bin/rpython -Ojit pypy/goal/targetpypystandalone.py + cd pypy/goal && $(RUNINTERP) ../../rpython/bin/rpython -Ojit targetpypystandalone.py # Note: the -jN option, or MAKEFLAGS=-jN, are not usable. They are # replaced with an opaque --jobserver option by the time this Makefile @@ -40,4 +40,4 @@ # http://lists.gnu.org/archive/html/help-make/2010-08/msg00106.html cffi_imports: pypy-c - PYTHONPATH=. ./pypy-c pypy/tool/build_cffi_imports.py || /bin/true + PYTHONPATH=. pypy/goal/pypy-c pypy/tool/build_cffi_imports.py || /bin/true diff --git a/lib-python/2.7/ctypes/__init__.py b/lib-python/2.7/ctypes/__init__.py --- a/lib-python/2.7/ctypes/__init__.py +++ b/lib-python/2.7/ctypes/__init__.py @@ -361,17 +361,20 @@ if handle is None: if flags & _FUNCFLAG_CDECL: -
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Manuel JacobBranch: py3.6 Changeset: r92170:3cbf980069f5 Date: 2017-07-22 03:37 +0200 http://bitbucket.org/pypy/pypy/changeset/3cbf980069f5/ Log:hg merge py3.5 diff --git a/lib_pypy/_cffi_ssl/README.md b/lib_pypy/_cffi_ssl/README.md --- a/lib_pypy/_cffi_ssl/README.md +++ b/lib_pypy/_cffi_ssl/README.md @@ -5,9 +5,15 @@ it renames the compiled shared object to _pypy_openssl.so (which means that cryptography can ship their own cffi backend) -NOTE: currently, we have changed ``_cffi_src/openssl/callbacks.py`` to -not rely on the CPython C API, and ``_cffi_src/utils.py`` for issue #2575 -(29c9a89359e4). (The first change is now backported.) +NOTE: currently, we have the following changes: + +* ``_cffi_src/openssl/callbacks.py`` to not rely on the CPython C API + (this change is now backported) + +* ``_cffi_src/utils.py`` for issue #2575 (29c9a89359e4) + +* ``_cffi_src/openssl/x509_vfy.py`` for issue #2605 (ca4d0c90f5a1) + # Tests? diff --git a/lib_pypy/_cffi_ssl/_cffi_src/openssl/x509_vfy.py b/lib_pypy/_cffi_ssl/_cffi_src/openssl/x509_vfy.py --- a/lib_pypy/_cffi_ssl/_cffi_src/openssl/x509_vfy.py +++ b/lib_pypy/_cffi_ssl/_cffi_src/openssl/x509_vfy.py @@ -221,10 +221,16 @@ static const long X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM = 0; static const long X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED = 0; static const long X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 = 0; +#ifndef X509_V_ERR_HOSTNAME_MISMATCH static const long X509_V_ERR_HOSTNAME_MISMATCH = 0; +#endif +#ifndef X509_V_ERR_EMAIL_MISMATCH static const long X509_V_ERR_EMAIL_MISMATCH = 0; +#endif +#ifndef X509_V_ERR_IP_ADDRESS_MISMATCH static const long X509_V_ERR_IP_ADDRESS_MISMATCH = 0; #endif +#endif /* OpenSSL 1.0.2beta2+ verification parameters */ #if CRYPTOGRAPHY_OPENSSL_102BETA2_OR_GREATER && \ 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 @@ -462,6 +462,12 @@ fwrite(buf, 1, count, fp) return 0 +@cts.decl(""" +Py_ssize_t PyObject_LengthHint(PyObject *o, Py_ssize_t defaultvalue)""", +error=-1) +def PyObject_LengthHint(space, w_o, defaultvalue): +return space.length_hint(w_o, defaultvalue) + @cpython_api([lltype.Signed], lltype.Void) def _PyPyGC_AddMemoryPressure(space, report): from rpython.rlib import rgc diff --git a/pypy/module/cpyext/test/test_object.py b/pypy/module/cpyext/test/test_object.py --- a/pypy/module/cpyext/test/test_object.py +++ b/pypy/module/cpyext/test/test_object.py @@ -349,6 +349,27 @@ assert type(module.asbytes(sub1(b''))) is bytes assert type(module.asbytes(sub2(b''))) is sub2 +def test_LengthHint(self): +import operator +class WithLen: +def __len__(self): +return 1 +def __length_hint__(self): +return 42 +class NoLen: +def __length_hint__(self): +return 2 +module = self.import_extension('test_LengthHint', [ +('length_hint', 'METH_VARARGS', + """ + PyObject *obj = PyTuple_GET_ITEM(args, 0); + Py_ssize_t i = PyLong_AsSsize_t(PyTuple_GET_ITEM(args, 1)); + return PyLong_FromSsize_t(PyObject_LengthHint(obj, i)); + """)]) +assert module.length_hint(WithLen(), 5) == operator.length_hint(WithLen(), 5) == 1 +assert module.length_hint(NoLen(), 5) == operator.length_hint(NoLen(), 5) == 2 +assert module.length_hint(object(), 5) == operator.length_hint(object(), 5) == 5 + def test_add_memory_pressure(self): self.reset_memory_pressure()# for the potential skip module = self.import_extension('foo', [ @@ -528,4 +549,3 @@ Py_RETURN_NONE; """)]) assert module.release() is None - diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py --- a/pypy/objspace/std/bytesobject.py +++ b/pypy/objspace/std/bytesobject.py @@ -365,8 +365,8 @@ characters, all remaining cased characters have lowercase. """ -@unwrap_spec(w_deletechars=WrappedDefault('')) -def descr_translate(self, space, w_table, w_deletechars): +@unwrap_spec(w_delete=WrappedDefault('')) +def descr_translate(self, space, w_table, w_delete): """B.translate(table[, deletechars]) -> copy of B Return a copy of the string B, where all characters occurring diff --git a/pypy/objspace/std/stringmethods.py b/pypy/objspace/std/stringmethods.py --- a/pypy/objspace/std/stringmethods.py +++ b/pypy/objspace/std/stringmethods.py @@ -742,8 +742,8 @@ DEFAULT_NOOP_TABLE = ''.join([chr(i) for i in range(256)]) # for bytes and bytearray, overridden by unicode -@unwrap_spec(w_deletechars=WrappedDefault('')) -def descr_translate(self, space, w_table, w_deletechars): +@unwrap_spec(w_delete=WrappedDefault('')) +def
[pypy-commit] pypy py3.6: hg merge py3.5
Author: Manuel JacobBranch: py3.6 Changeset: r91914:73c89dbe9896 Date: 2017-07-17 20:47 +0200 http://bitbucket.org/pypy/pypy/changeset/73c89dbe9896/ Log:hg merge py3.5 diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py --- a/pypy/objspace/std/bytesobject.py +++ b/pypy/objspace/std/bytesobject.py @@ -748,14 +748,17 @@ if space.isinstance_w(w_source, space.w_unicode): raise oefmt(space.w_TypeError, "cannot convert a (unicode) str object to bytes") +return _from_byte_sequence(space, w_source) -# sequence of bytes + +def _from_byte_sequence(space, w_source): +# Split off in a separate function for the JIT's benefit w_result = space.appexec([w_source], """(seq): result = bytearray() for i in seq: result.append(i) return result""") -return w_result.getdata() +return ''.join(w_result.getdata()) W_BytesObject.typedef = TypeDef( "bytes", None, None, "read", ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit