Commit 291d94f7 authored by Matti Picus's avatar Matti Picus
Browse files

merge default into branch

--HG--
branch : buffer-interface
......@@ -27,3 +27,6 @@ b0a649e90b6642251fb4a765fe5b27a97b1319a9 release-5.1.1
40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2
c09c19272c990a0611b17569a0085ad1ab00c8ff release-pypy2.7-v5.3
7e8df3df96417c16c2d55b41352ec82c9c69c978 release-pypy2.7-v5.3.1
68bb3510d8212ae9efb687e12e58c09d29e74f87 release-pypy2.7-v5.4.0
68bb3510d8212ae9efb687e12e58c09d29e74f87 release-pypy2.7-v5.4.0
77392ad263504df011ccfcabf6a62e21d04086d0 release-pypy2.7-v5.4.0
......@@ -74,6 +74,7 @@ copyrighted by one or more of the following people and organizations:
Seo Sanghyeon
Ronny Pfannschmidt
Justin Peel
Raffael Tfirst
David Edelsohn
Anders Hammarquist
Jakub Gustak
......@@ -117,7 +118,6 @@ copyrighted by one or more of the following people and organizations:
Wenzhu Man
John Witulski
Laurence Tratt
Raffael Tfirst
Ivan Sichmann Freitas
Greg Price
Dario Bertini
......@@ -141,6 +141,7 @@ copyrighted by one or more of the following people and organizations:
tav
Taavi Burns
Georg Brandl
Nicolas Truessel
Bert Freudenberg
Stian Andreassen
Wanja Saatkamp
......@@ -211,6 +212,7 @@ copyrighted by one or more of the following people and organizations:
Vaibhav Sood
Alan McIntyre
Alexander Sedov
p_zieschang@yahoo.de
Attila Gobi
Jasper.Schulz
Christopher Pope
......@@ -221,6 +223,7 @@ copyrighted by one or more of the following people and organizations:
Arjun Naik
Valentina Mukhamedzhanova
Stefano Parmesan
touilleMan
Alexis Daboville
Jens-Uwe Mager
Carl Meyer
......@@ -229,12 +232,14 @@ copyrighted by one or more of the following people and organizations:
Gabriel
Lukas Vacek
Kunal Grover
Aaron Gallagher
Andrew Dalke
Sylvain Thenault
Jakub Stasiak
Nathan Taylor
Vladimir Kryachko
Omer Katz
Mark Williams
Jacek Generowicz
Alejandro J. Cura
Jacob Oscarson
......@@ -355,12 +360,15 @@ copyrighted by one or more of the following people and organizations:
yasirs
Michael Chermside
Anna Ravencroft
pizi
Andrey Churin
Dan Crosta
Eli Stevens
Tobias Diaz
Julien Phalip
Roman Podoliaka
Dan Loewenherz
werat
Heinrich-Heine University, Germany
Open End AB (formerly AB Strakt), Sweden
......
......@@ -498,7 +498,10 @@ class Class(PyCollector):
""" Collector for test methods. """
def collect(self):
if hasinit(self.obj):
pytest.skip("class %s.%s with __init__ won't get collected" % (
# XXX used to be skip(), but silently skipping classes
# XXX just because they have been written long ago is
# XXX imho a very, very, very bad idea
pytest.fail("class %s.%s with __init__ won't get collected" % (
self.obj.__module__,
self.obj.__name__,
))
......
......@@ -122,22 +122,24 @@ def customize_compiler(compiler):
"""Dummy method to let some easy_install packages that have
optional C speedup components.
"""
def customize(executable, flags):
command = compiler.executables[executable] + flags
setattr(compiler, executable, command)
if compiler.compiler_type == "unix":
compiler.compiler_so.extend(['-O2', '-fPIC', '-Wimplicit'])
compiler.shared_lib_extension = get_config_var('SO')
if "CPPFLAGS" in os.environ:
cppflags = shlex.split(os.environ["CPPFLAGS"])
compiler.compiler.extend(cppflags)
compiler.compiler_so.extend(cppflags)
compiler.linker_so.extend(cppflags)
for executable in ('compiler', 'compiler_so', 'linker_so'):
customize(executable, cppflags)
if "CFLAGS" in os.environ:
cflags = shlex.split(os.environ["CFLAGS"])
compiler.compiler.extend(cflags)
compiler.compiler_so.extend(cflags)
compiler.linker_so.extend(cflags)
for executable in ('compiler', 'compiler_so', 'linker_so'):
customize(executable, cflags)
if "LDFLAGS" in os.environ:
ldflags = shlex.split(os.environ["LDFLAGS"])
compiler.linker_so.extend(ldflags)
customize('linker_so', ldflags)
from sysconfig_cpython import (
......
......@@ -342,7 +342,7 @@ class CFuncPtr(_CData):
thisarg = cast(thisvalue, POINTER(POINTER(c_void_p)))
keepalives, newargs, argtypes, outargs, errcheckargs = (
self._convert_args(argtypes, args[1:], kwargs))
newargs.insert(0, thisvalue.value)
newargs.insert(0, thisarg)
argtypes.insert(0, c_void_p)
else:
thisarg = None
......
......@@ -44,6 +44,7 @@ appropriate measure but it's something)::
Seo Sanghyeon
Ronny Pfannschmidt
Justin Peel
Raffael Tfirst
David Edelsohn
Anders Hammarquist
Jakub Gustak
......@@ -87,7 +88,6 @@ appropriate measure but it's something)::
Wenzhu Man
John Witulski
Laurence Tratt
Raffael Tfirst
Ivan Sichmann Freitas
Greg Price
Dario Bertini
......@@ -111,6 +111,7 @@ appropriate measure but it's something)::
tav
Taavi Burns
Georg Brandl
Nicolas Truessel
Bert Freudenberg
Stian Andreassen
Wanja Saatkamp
......@@ -181,6 +182,7 @@ appropriate measure but it's something)::
Vaibhav Sood
Alan McIntyre
Alexander Sedov
p_zieschang@yahoo.de
Attila Gobi
Jasper.Schulz
Christopher Pope
......@@ -191,6 +193,7 @@ appropriate measure but it's something)::
Arjun Naik
Valentina Mukhamedzhanova
Stefano Parmesan
touilleMan
Alexis Daboville
Jens-Uwe Mager
Carl Meyer
......@@ -199,12 +202,14 @@ appropriate measure but it's something)::
Gabriel
Lukas Vacek
Kunal Grover
Aaron Gallagher
Andrew Dalke
Sylvain Thenault
Jakub Stasiak
Nathan Taylor
Vladimir Kryachko
Omer Katz
Mark Williams
Jacek Generowicz
Alejandro J. Cura
Jacob Oscarson
......@@ -325,9 +330,12 @@ appropriate measure but it's something)::
yasirs
Michael Chermside
Anna Ravencroft
pizi
Andrey Churin
Dan Crosta
Eli Stevens
Tobias Diaz
Julien Phalip
Roman Podoliaka
Dan Loewenherz
werat
......@@ -3,7 +3,8 @@ PyPy2.7 v5.4
============
We have released PyPy2.7 v5.4, a little under two months after PyPy2.7 v5.3.
This new PyPy2.7 release includes further improvements to our C-API compatability layer (cpyext), enabling us to pass over 99% of the upstream
This new PyPy2.7 release includes incremental improvements to our C-API
compatability layer (cpyext), enabling us to pass over 99% of the upstream
numpy `test suite`_. We updated built-in cffi_ support to version 1.8,
which now supports the "limited API" mode for c-extensions on
CPython >=3.2.
......@@ -12,9 +13,7 @@ We improved tooling for the PyPy JIT_, and expanded VMProf
support to OpenBSD and Dragon Fly BSD
As always, this release fixed many issues and bugs raised by the
growing community of PyPy users.
XXXXX MORE ???
growing community of PyPy users. We strongly recommend updating.
You can download the PyPy2.7 v5.4 release here:
......@@ -110,8 +109,8 @@ Other Highlights (since 5.3 released in June 2016)
* (RPython) add `rposix_scandir` portably, needed for Python 3.5
* Support for memoryview attributes (format, itemsize, ...) which also
adds support for `PyMemoryView_FromObject`
* Increased but incomplete support for memoryview attributes (format,
itemsize, ...) which also adds support for `PyMemoryView_FromObject`
* Bug Fixes
......@@ -153,10 +152,6 @@ Other Highlights (since 5.3 released in June 2016)
* Make `hash(-1)` return -2, as CPython does, and fix all the
ancilary places this matters
* 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
* Fix `PyNumber_Check()` to behave more like CPython
* (VMProf) Try hard to not miss any Python-level frame in the
......@@ -169,6 +164,10 @@ Other Highlights (since 5.3 released in June 2016)
* Fix the mapdict cache for subclasses of builtin types that
provide a dict
* 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
* Performance improvements:
* Add a before_call()-like equivalent before a few operations like
......
......@@ -5,4 +5,5 @@ What's new in PyPy2.7 5.4+
.. this is a revision shortly after release-pypy2.7-v5.4
.. startrev: 522736f816dc
.. branch: rpython-resync
Backport rpython changes made directly on the py3k and py3.5 branches.
......@@ -23,6 +23,14 @@ class W_Super(W_Root):
self.w_objtype = w_type
self.w_self = w_obj_or_type
def descr_repr(self, space):
if self.w_objtype is not None:
objtype_name = "<%s object>" % self.w_objtype.getname(space)
else:
objtype_name = 'NULL'
return space.wrap("<super: <class '%s'>, %s>" % (
self.w_starttype.getname(space), objtype_name))
def get(self, space, w_obj, w_type=None):
if self.w_self is None or space.is_w(w_obj, space.w_None):
return self
......@@ -84,7 +92,10 @@ W_Super.typedef = TypeDef(
'super',
__new__ = generic_new_descr(W_Super),
__init__ = interp2app(W_Super.descr_init),
__repr__ = interp2app(W_Super.descr_repr),
__thisclass__ = interp_attrproperty_w("w_starttype", W_Super),
__self__ = interp_attrproperty_w("w_self", W_Super),
__self_class__ = interp_attrproperty_w("w_objtype", W_Super),
__getattribute__ = interp2app(W_Super.getattribute),
__get__ = interp2app(W_Super.get),
__doc__ = """\
......
......@@ -38,6 +38,8 @@ def descr_classobj_new(space, w_subtype, w_name, w_bases, w_dict):
class W_ClassObject(W_Root):
_immutable_fields_ = ['bases_w?[*]', 'w_dict?']
def __init__(self, space, w_name, bases, w_dict):
self.name = space.str_w(w_name)
make_sure_not_resized(bases)
......@@ -75,6 +77,7 @@ class W_ClassObject(W_Root):
"__bases__ items must be classes")
self.bases_w = bases_w
@jit.unroll_safe
def is_subclass_of(self, other):
assert isinstance(other, W_ClassObject)
if self is other:
......@@ -313,7 +316,7 @@ class W_InstanceObject(W_Root):
# This method ignores the instance dict and the __getattr__.
# Returns None if not found.
assert isinstance(name, str)
w_value = self.w_class.lookup(space, name)
w_value = jit.promote(self.w_class).lookup(space, name)
if w_value is None:
return None
w_descr_get = space.lookup(w_value, '__get__')
......
......@@ -250,6 +250,24 @@ class AppTestBuiltinApp:
assert super(B, B()).__thisclass__ is B
assert super(A, B()).__thisclass__ is A
def test_super_self_selfclass(self):
class A(object):
pass
class B(A):
pass
b = B()
assert super(A, b).__self__ is b
assert super(A).__self__ is None
assert super(A, b).__self_class__ is B
assert super(A).__self_class__ is None
def test_super_repr(self):
class A(object):
def __repr__(self):
return super(A, self).__repr__() + '!'
assert repr(A()).endswith('>!')
assert repr(super(A, A())) == "<super: <class 'A'>, <A object>>"
def test_property_docstring(self):
assert property.__doc__.startswith('property')
......
from pypy.interpreter.mixedmodule import MixedModule
from pypy.interpreter.mixedmodule import MixedModule
class Module(MixedModule):
......@@ -7,7 +7,7 @@ class Module(MixedModule):
interpleveldefs = {
'CODESIZE': 'space.wrap(interp_sre.CODESIZE)',
'MAGIC': 'space.wrap(interp_sre.MAGIC)',
'MAGIC': 'space.newint(20031017)',
'MAXREPEAT': 'space.wrap(interp_sre.MAXREPEAT)',
'compile': 'interp_sre.W_SRE_Pattern',
'getlower': 'interp_sre.w_getlower',
......
......@@ -14,7 +14,7 @@ from rpython.rlib.rstring import StringBuilder, UnicodeBuilder
# Constants and exposed functions
from rpython.rlib.rsre import rsre_core
from rpython.rlib.rsre.rsre_char import MAGIC, CODESIZE, MAXREPEAT, getlower, set_unicode_db
from rpython.rlib.rsre.rsre_char import CODESIZE, MAXREPEAT, getlower, set_unicode_db
@unwrap_spec(char_ord=int, flags=int)
......
......@@ -123,5 +123,4 @@ def PyImport_ExecCodeModuleEx(space, name, w_code, pathname):
pathname = code.co_filename
w_mod = importing.add_module(space, w_name)
space.setattr(w_mod, space.wrap('__file__'), space.wrap(pathname))
importing.exec_code_module(space, w_mod, code)
return w_mod
return importing.exec_code_module(space, w_mod, code, w_name)
......@@ -92,10 +92,20 @@ def compile_extension_module(space, modname, include_dirs=[],
link_extra=link_extra,
libraries=libraries)
from pypy.module.imp.importing import get_so_extension
pydname = soname.new(purebasename=modname, ext=get_so_extension(space))
ext = get_so_extension(space)
pydname = soname.new(purebasename=modname, ext=ext)
soname.rename(pydname)
return str(pydname)
def get_so_suffix():
from imp import get_suffixes, C_EXTENSION
for suffix, mode, typ in get_suffixes():
if typ == C_EXTENSION:
return suffix
else:
raise RuntimeError("This interpreter does not define a filename "
"suffix for C extensions!")
def compile_extension_module_applevel(space, modname, include_dirs=[],
source_files=None, source_strings=None):
"""
......@@ -126,13 +136,9 @@ def compile_extension_module_applevel(space, modname, include_dirs=[],
source_strings=source_strings,
compile_extra=compile_extra,
link_extra=link_extra)
from imp import get_suffixes, C_EXTENSION
pydname = soname
for suffix, mode, typ in get_suffixes():
if typ == C_EXTENSION:
pydname = soname.new(purebasename=modname, ext=suffix)
soname.rename(pydname)
break
ext = get_so_suffix()
pydname = soname.new(purebasename=modname, ext=ext)
soname.rename(pydname)
return str(pydname)
def freeze_refcnts(self):
......@@ -145,6 +151,24 @@ def freeze_refcnts(self):
#state.print_refcounts()
self.frozen_ll2callocations = set(ll2ctypes.ALLOCATED.values())
class FakeSpace(object):
"""Like TinyObjSpace, but different"""
def __init__(self, config):
from distutils.sysconfig import get_python_inc
self.config = config
self.include_dir = get_python_inc()
def passthrough(self, arg):
return arg
listview = passthrough
str_w = passthrough
def unwrap(self, args):
try:
return args.str_w(None)
except:
return args
class LeakCheckingTest(object):
"""Base class for all cpyext tests."""
spaceconfig = dict(usemodules=['cpyext', 'thread', '_rawffi', 'array',
......@@ -433,21 +457,8 @@ class AppTestCpythonExtensionBase(LeakCheckingTest):
self.imported_module_names = []
if self.runappdirect:
fake = FakeSpace(self.space.config)
def interp2app(func):
from distutils.sysconfig import get_python_inc
class FakeSpace(object):
def passthrough(self, arg):
return arg
listview = passthrough
str_w = passthrough
def unwrap(self, args):
try:
return args.str_w(None)
except:
return args
fake = FakeSpace()
fake.include_dir = get_python_inc()
fake.config = self.space.config
def run(*args, **kwargs):
for k in kwargs.keys():
if k not in func.unwrap_spec and not k.startswith('w_'):
......
......@@ -597,6 +597,11 @@ def load_c_extension(space, filename, modulename):
@jit.dont_look_inside
def load_module(space, w_modulename, find_info, reuse=False):
"""Like load_module() in CPython's import.c, this will normally
make a module object, store it in sys.modules, execute code in it,
and then fetch it again from sys.modules. But this logic is not
used if we're calling a PEP302 loader.
"""
if find_info is None:
return
......@@ -625,17 +630,15 @@ def load_module(space, w_modulename, find_info, reuse=False):
try:
if find_info.modtype == PY_SOURCE:
load_source_module(
return load_source_module(
space, w_modulename, w_mod,
find_info.filename, find_info.stream.readall(),
find_info.stream.try_to_find_file_descriptor())
return w_mod
elif find_info.modtype == PY_COMPILED:
magic = _r_long(find_info.stream)
timestamp = _r_long(find_info.stream)
load_compiled_module(space, w_modulename, w_mod, find_info.filename,
return load_compiled_module(space, w_modulename, w_mod, find_info.filename,
magic, timestamp, find_info.stream.readall())
return w_mod
elif find_info.modtype == PKG_DIRECTORY:
w_path = space.newlist([space.wrap(find_info.filename)])
space.setattr(w_mod, space.wrap('__path__'), w_path)
......@@ -644,14 +647,13 @@ def load_module(space, w_modulename, find_info, reuse=False):
if find_info is None:
return w_mod
try:
load_module(space, w_modulename, find_info, reuse=True)
w_mod = load_module(space, w_modulename, find_info,
reuse=True)
finally:
try:
find_info.stream.close()
except StreamErrors:
pass
# fetch the module again, in case of "substitution"
w_mod = check_sys_modules(space, w_modulename)
return w_mod
elif find_info.modtype == C_EXTENSION and has_so_extension(space):
load_c_extension(space, find_info.filename, space.str_w(w_modulename))
......@@ -677,13 +679,6 @@ def load_part(space, w_path, prefix, partname, w_parent, tentative):
try:
if find_info:
w_mod = load_module(space, w_modulename, find_info)
try:
w_mod = space.getitem(space.sys.get("modules"),
w_modulename)
except OperationError as oe:
if not oe.match(space, space.w_KeyError):
raise
raise OperationError(space.w_ImportError, w_modulename)
if w_parent is not None:
space.setattr(w_parent, space.wrap(partname), w_mod)
return w_mod
......@@ -875,20 +870,32 @@ def parse_source_module(space, pathname, source):
pycode = ec.compiler.compile(source, pathname, 'exec', 0)
return pycode
def exec_code_module(space, w_mod, code_w):
def exec_code_module(space, w_mod, code_w, w_modulename, check_afterwards=True):
"""
Execute a code object in the module's dict. Returns
'sys.modules[modulename]', which must exist.
"""
w_dict = space.getattr(w_mod, space.wrap('__dict__'))
space.call_method(w_dict, 'setdefault',
space.wrap('__builtins__'),
space.wrap(space.builtin))
code_w.exec_code(space, w_dict, w_dict)
if check_afterwards:
w_mod = check_sys_modules(space, w_modulename)
if w_mod is None:
raise oefmt(space.w_ImportError,
"Loaded module %R not found in sys.modules",
w_modulename)
return w_mod
@jit.dont_look_inside
def load_source_module(space, w_modulename, w_mod, pathname, source, fd,
write_pyc=True):
write_pyc=True, check_afterwards=True):
"""
Load a source module from a given file and return its module
object.
Load a source module from a given file. Returns the result
of sys.modules[modulename], which must exist.
"""
w = space.wrap
......@@ -927,9 +934,8 @@ def load_source_module(space, w_modulename, w_mod, pathname, source, fd,
code_w.remove_docstrings(space)
update_code_filenames(space, code_w, pathname)
exec_code_module(space, w_mod, code_w)
return w_mod
return exec_code_module(space, w_mod, code_w, w_modulename,
check_afterwards=check_afterwards)
def update_code_filenames(space, code_w, pathname, oldname=None):
assert isinstance(code_w, PyCode)
......@@ -1012,10 +1018,10 @@ def read_compiled_module(space, cpathname, strbuf):
@jit.dont_look_inside
def load_compiled_module(space, w_modulename, w_mod, cpathname, magic,
timestamp, source):
timestamp, source, check_afterwards=True):
"""
Load a module from a compiled file, execute it, and return its
module object.
Load a module from a compiled file and execute it. Returns
'sys.modules[modulename]', which must exist.
"""
log_pyverbose(space, 1, "import %s # compiled from %s\n" %
(space.str_w(w_modulename), cpathname))
......@@ -1032,9 +1038,8 @@ def load_compiled_module(space, w_modulename, w_mod, cpathname, magic,
if optimize >= 2:
code_w.remove_docstrings(space)
exec_code_module(space, w_mod, code_w)
return w_mod
return exec_code_module(space, w_mod, code_w, w_modulename,
check_afterwards=check_afterwards)
def open_exclusive(space, cpathname, mode):
try:
......
......@@ -98,33 +98,35 @@ def load_source(space, w_modulename, w_filename, w_file=None):
w_mod = space.wrap(Module(space, w_modulename))
importing._prepare_module(space, w_mod, filename, None)
importing.load_source_module(
w_mod = importing.load_source_module(
space, w_modulename, w_mod,
filename, stream.readall(), stream.try_to_find_file_descriptor())
if space.is_none(w_file):
stream.close()
return w_mod
@unwrap_spec(filename='str0')
def _run_compiled_module(space, w_modulename, filename, w_file, w_module):
@unwrap_spec(filename='str0', check_afterwards=int)
def _run_compiled_module(space, w_modulename, filename, w_file, w_module,
check_afterwards=False):
# the function 'imp._run_compiled_module' is a pypy-only extension
stream = get_file(space, w_file, filename, 'rb')
magic = importing._r_long(stream)
timestamp = importing._r_long(stream)
importing.load_compiled_module(
w_mod = importing.load_compiled_module(
space, w_modulename, w_module, filename, magic, timestamp,
stream.readall())
stream.readall(), check_afterwards=check_afterwards)