Author: Matti Picus <[email protected]>
Branch: cpyext-injection
Changeset: r91664:36d878c36842
Date: 2017-06-30 18:26 -0400
http://bitbucket.org/pypy/pypy/changeset/36d878c36842/
Log: merge default into branch
diff too long, truncating to 2000 out of 60621 lines
diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -1,6 +1,6 @@
syntax: glob
*.py[co]
-*.sw[po]
+*.sw[pon]
*~
.*.swp
.idea
@@ -8,6 +8,8 @@
.pydevproject
__pycache__
+.cache/
+.gdb_history
syntax: regexp
^testresult$
^site-packages$
@@ -49,6 +51,11 @@
^rpython/translator/goal/target.+-c$
^rpython/translator/goal/.+\.exe$
^rpython/translator/goal/.+\.dll$
+^rpython/rlib/rvmprof/src/shared/libbacktrace/Makefile$
+^rpython/rlib/rvmprof/src/shared/libbacktrace/config.guess$
+^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/goal/pypy-translation-snapshot$
^pypy/goal/pypy-c
^pypy/goal/.+\.exe$
@@ -80,6 +87,7 @@
.hypothesis/
^release/
^rpython/_cache$
-^\.cache$
pypy/module/cppyy/.+/*\.pcm
+
+
diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -36,3 +36,7 @@
aff251e543859ce4508159dd9f1a82a2f553de00 release-pypy2.7-v5.6.0
fa3249d55d15b9829e1be69cdf45b5a44cec902d release-pypy2.7-v5.7.0
b16a4363e930f6401bceb499b9520955504c6cb0 release-pypy3.5-v5.7.0
+1aa2d8e03cdfab54b7121e93fda7e98ea88a30bf release-pypy2.7-v5.7.1
+2875f328eae2216a87f3d6f335092832eb031f56 release-pypy3.5-v5.7.1
+c925e73810367cd960a32592dd7f728f436c125c release-pypy2.7-v5.8.0
+a37ecfe5f142bc971a86d17305cc5d1d70abec64 release-pypy3.5-v5.8.0
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -39,11 +39,11 @@
Armin Rigo
Maciej Fijalkowski
- Carl Friedrich Bolz
+ Carl Friedrich Bolz-Tereick
Amaury Forgeot d'Arc
Antonio Cuni
+ Matti Picus
Samuele Pedroni
- Matti Picus
Ronan Lamy
Alex Gaynor
Philip Jenvey
@@ -101,28 +101,28 @@
Vincent Legoll
Michael Foord
Stephan Diehl
+ Stefano Rivera
Stefan Schwarzer
Tomek Meka
Valentino Volonghi
- Stefano Rivera
Patrick Maupin
Devin Jeanpierre
Bob Ippolito
Bruno Gola
David Malcolm
Jean-Paul Calderone
+ Squeaky
Edd Barrett
- Squeaky
Timo Paulssen
Marius Gedminas
Alexandre Fayolle
Simon Burton
Nicolas Truessel
Martin Matusiak
+ Laurence Tratt
Wenzhu Man
Konstantin Lopuhin
John Witulski
- Laurence Tratt
Greg Price
Ivan Sichmann Freitas
Dario Bertini
@@ -149,13 +149,13 @@
Stian Andreassen
Wanja Saatkamp
Mike Blume
+ Joannah Nanjekye
Gerald Klix
Oscar Nierstrasz
Rami Chowdhury
Stefan H. Muller
- Joannah Nanjekye
+ Tim Felgentreff
Eugene Oden
- Tim Felgentreff
Jeff Terrace
Henry Mason
Vasily Kuznetsov
@@ -164,11 +164,11 @@
Dusty Phillips
Lukas Renggli
Guenter Jantzen
+ Jasper Schulz
Ned Batchelder
Amit Regmi
Anton Gulenko
Sergey Matyunin
- Jasper Schulz
Andrew Chambers
Nicolas Chauvat
Andrew Durdin
@@ -183,6 +183,7 @@
Gintautas Miliauskas
Lucian Branescu Mihaila
anatoly techtonik
+ Dodan Mihai
Karl Bartel
Gabriel Lavoie
Jared Grubb
@@ -220,12 +221,14 @@
Vaibhav Sood
Reuben Cummings
Attila Gobi
+ Alecsandru Patrascu
Christopher Pope
Tristan Arthur
Christian Tismer
Dan Stromberg
Carl Meyer
Florin Papa
+ Jens-Uwe Mager
Valentina Mukhamedzhanova
Stefano Parmesan
touilleMan
@@ -264,7 +267,6 @@
Dan Buch
Lene Wagner
Tomo Cocoa
- Alecsandru Patrascu
David Lievens
Neil Blakey-Milner
Henrik Vendelbo
@@ -303,6 +305,7 @@
Anna Katrina Dominguez
Kim Jin Su
Amber Brown
+ Nate Bragg
Ben Darnell
Juan Francisco Cantero Hurtado
Godefroid Chappelle
@@ -340,11 +343,13 @@
Jim Hunziker
shoma hosaka
Buck Golemon
+ Iraklis D.
JohnDoe
yrttyr
Michael Chermside
Anna Ravencroft
remarkablerocket
+ Petre Vijiac
Berker Peksag
Christian Muirhead
soareschen
diff --git a/include/README b/include/README
--- a/include/README
+++ b/include/README
@@ -1,7 +1,11 @@
This directory contains all the include files needed to build cpython
extensions with PyPy. Note that these are just copies of the original headers
-that are in pypy/module/cpyext/include: they are automatically copied from
-there during translation.
+that are in pypy/module/cpyext/{include,parse}: they are automatically copied
+from there during translation.
-Moreover, pypy_decl.h and pypy_macros.h are automatically generated, also
-during translation.
+Moreover, some pypy-specific files are automatically generated, also during
+translation. Currently they are:
+* pypy_decl.h
+* pypy_macros.h
+* pypy_numpy.h
+* pypy_structmember_decl.h
diff --git a/lib-python/2.7/ctypes/test/test_unaligned_structures.py
b/lib-python/2.7/ctypes/test/test_unaligned_structures.py
--- a/lib-python/2.7/ctypes/test/test_unaligned_structures.py
+++ b/lib-python/2.7/ctypes/test/test_unaligned_structures.py
@@ -37,7 +37,10 @@
for typ in byteswapped_structures:
## print >> sys.stderr, typ.value
self.assertEqual(typ.value.offset, 1)
- o = typ()
+ try:
+ o = typ()
+ except NotImplementedError as e:
+ self.skipTest(str(e)) # for PyPy
o.value = 4
self.assertEqual(o.value, 4)
diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py
b/lib-python/2.7/distutils/sysconfig_pypy.py
--- a/lib-python/2.7/distutils/sysconfig_pypy.py
+++ b/lib-python/2.7/distutils/sysconfig_pypy.py
@@ -61,12 +61,12 @@
def _init_posix():
"""Initialize the module as appropriate for POSIX systems."""
g = {}
- g['CC'] = "gcc -pthread"
- g['CXX'] = "g++ -pthread"
+ g['CC'] = "cc -pthread"
+ g['CXX'] = "c++ -pthread"
g['OPT'] = "-DNDEBUG -O2"
g['CFLAGS'] = "-DNDEBUG -O2"
g['CCSHARED'] = "-fPIC"
- g['LDSHARED'] = "gcc -pthread -shared"
+ g['LDSHARED'] = "cc -pthread -shared"
g['SO'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION][0]
g['AR'] = "ar"
g['ARFLAGS'] = "rc"
diff --git a/lib-python/2.7/warnings.py b/lib-python/2.7/warnings.py
--- a/lib-python/2.7/warnings.py
+++ b/lib-python/2.7/warnings.py
@@ -309,9 +309,12 @@
def __init__(self, message, category, filename, lineno, file=None,
line=None):
- local_values = locals()
- for attr in self._WARNING_DETAILS:
- setattr(self, attr, local_values[attr])
+ self.message = message
+ self.category = category
+ self.filename = filename
+ self.lineno = lineno
+ self.file = file
+ self.line = line
self._category_name = category.__name__ if category else None
def __str__(self):
diff --git a/lib-python/2.7/zipfile.py b/lib-python/2.7/zipfile.py
--- a/lib-python/2.7/zipfile.py
+++ b/lib-python/2.7/zipfile.py
@@ -622,19 +622,23 @@
"""Read and return up to n bytes.
If the argument is omitted, None, or negative, data is read and
returned until EOF is reached..
"""
- buf = ''
+ # PyPy modification: don't do repeated string concatenation
+ buf = []
+ lenbuf = 0
if n is None:
n = -1
while True:
if n < 0:
data = self.read1(n)
- elif n > len(buf):
- data = self.read1(n - len(buf))
+ elif n > lenbuf:
+ data = self.read1(n - lenbuf)
else:
- return buf
+ break
if len(data) == 0:
- return buf
- buf += data
+ break
+ lenbuf += len(data)
+ buf.append(data)
+ return "".join(buf)
def _update_crc(self, newdata, eof):
# Update the CRC using the given data.
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
@@ -76,17 +76,22 @@
return self._type_._alignmentofinstances()
def _CData_output(self, resarray, base=None, index=-1):
- # this seems to be a string if we're array of char, surprise!
- from ctypes import c_char, c_wchar
- if self._type_ is c_char:
- return _rawffi.charp2string(resarray.buffer, self._length_)
- if self._type_ is c_wchar:
- return _rawffi.wcharp2unicode(resarray.buffer, self._length_)
+ from _rawffi.alt import types
+ # If a char_p or unichar_p is received, skip the string interpretation
+ if base._ffiargtype != types.Pointer(types.char_p) and \
+ base._ffiargtype != types.Pointer(types.unichar_p):
+ # this seems to be a string if we're array of char, surprise!
+ from ctypes import c_char, c_wchar
+ if self._type_ is c_char:
+ return _rawffi.charp2string(resarray.buffer, self._length_)
+ if self._type_ is c_wchar:
+ return _rawffi.wcharp2unicode(resarray.buffer, self._length_)
res = self.__new__(self)
ffiarray = self._ffiarray.fromaddress(resarray.buffer, self._length_)
res._buffer = ffiarray
- res._base = base
- res._index = index
+ if base is not None:
+ res._base = base
+ res._index = index
return res
def _CData_retval(self, resbuffer):
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
@@ -64,8 +64,9 @@
res = object.__new__(self)
res.__class__ = self
res.__dict__['_buffer'] = resbuffer
- res.__dict__['_base'] = base
- res.__dict__['_index'] = index
+ if base is not None:
+ res.__dict__['_base'] = base
+ res.__dict__['_index'] = index
return res
def _CData_retval(self, resbuffer):
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
@@ -1,4 +1,3 @@
-
from _ctypes.basics import _CData, _CDataMeta, cdata_from_address
from _ctypes.primitive import SimpleType, _SimpleCData
from _ctypes.basics import ArgumentError, keepalive_key
@@ -9,13 +8,16 @@
import sys
import traceback
-try: from __pypy__ import builtinify
-except ImportError: builtinify = lambda f: f
+
+try:
+ from __pypy__ import builtinify
+except ImportError:
+ builtinify = lambda f: f
# XXX this file needs huge refactoring I fear
-PARAMFLAG_FIN = 0x1
-PARAMFLAG_FOUT = 0x2
+PARAMFLAG_FIN = 0x1
+PARAMFLAG_FOUT = 0x2
PARAMFLAG_FLCID = 0x4
PARAMFLAG_COMBINED = PARAMFLAG_FIN | PARAMFLAG_FOUT | PARAMFLAG_FLCID
@@ -24,9 +26,9 @@
PARAMFLAG_FIN,
PARAMFLAG_FIN | PARAMFLAG_FOUT,
PARAMFLAG_FIN | PARAMFLAG_FLCID
- )
+)
-WIN64 = sys.platform == 'win32' and sys.maxint == 2**63 - 1
+WIN64 = sys.platform == 'win32' and sys.maxint == 2 ** 63 - 1
def get_com_error(errcode, riid, pIunk):
@@ -35,6 +37,7 @@
from _ctypes import COMError
return COMError(errcode, None, None)
+
@builtinify
def call_function(func, args):
"Only for debugging so far: So that we can call CFunction instances"
@@ -94,14 +97,9 @@
"item %d in _argtypes_ has no from_param method" % (
i + 1,))
self._argtypes_ = list(argtypes)
- self._check_argtypes_for_fastpath()
+
argtypes = property(_getargtypes, _setargtypes)
- def _check_argtypes_for_fastpath(self):
- if all([hasattr(argtype, '_ffiargshape_') for argtype in
self._argtypes_]):
- fastpath_cls = make_fastpath_subclass(self.__class__)
- fastpath_cls.enable_fastpath_maybe(self)
-
def _getparamflags(self):
return self._paramflags
@@ -126,27 +124,26 @@
raise TypeError(
"paramflags must be a sequence of (int [,string [,value]])
"
"tuples"
- )
+ )
if not isinstance(flag, int):
raise TypeError(
"paramflags must be a sequence of (int [,string [,value]])
"
"tuples"
- )
+ )
_flag = flag & PARAMFLAG_COMBINED
if _flag == PARAMFLAG_FOUT:
typ = self._argtypes_[idx]
if getattr(typ, '_ffiargshape_', None) not in ('P', 'z', 'Z'):
raise TypeError(
"'out' parameter %d must be a pointer type, not %s"
- % (idx+1, type(typ).__name__)
- )
+ % (idx + 1, type(typ).__name__)
+ )
elif _flag not in VALID_PARAMFLAGS:
raise TypeError("paramflag value %d not supported" % flag)
self._paramflags = paramflags
paramflags = property(_getparamflags, _setparamflags)
-
def _getrestype(self):
return self._restype_
@@ -156,7 +153,7 @@
from ctypes import c_int
restype = c_int
if not (isinstance(restype, _CDataMeta) or restype is None or
- callable(restype)):
+ callable(restype)):
raise TypeError("restype must be a type, a callable, or None")
self._restype_ = restype
@@ -168,15 +165,18 @@
def _geterrcheck(self):
return getattr(self, '_errcheck_', None)
+
def _seterrcheck(self, errcheck):
if not callable(errcheck):
raise TypeError("The errcheck attribute must be callable")
self._errcheck_ = errcheck
+
def _delerrcheck(self):
try:
del self._errcheck_
except AttributeError:
pass
+
errcheck = property(_geterrcheck, _seterrcheck, _delerrcheck)
def _ffishapes(self, args, restype):
@@ -188,7 +188,7 @@
raise TypeError("invalid result type for callback function")
restype = restype._ffiargshape_
else:
- restype = 'O' # void
+ restype = 'O' # void
return argtypes, restype
def _set_address(self, address):
@@ -201,7 +201,7 @@
def __init__(self, *args):
self.name = None
- self._objects = {keepalive_key(0):self}
+ self._objects = {keepalive_key(0): self}
self._needs_free = True
# Empty function object -- this is needed for casts
@@ -222,10 +222,8 @@
if self._argtypes_ is None:
self._argtypes_ = []
self._ptr = self._getfuncptr_fromaddress(self._argtypes_, restype)
- self._check_argtypes_for_fastpath()
return
-
# A callback into python
if callable(argument) and not argsl:
self.callable = argument
@@ -259,7 +257,7 @@
if (sys.platform == 'win32' and isinstance(argument, (int, long))
and argsl):
ffiargs, ffires = self._ffishapes(self._argtypes_, self._restype_)
- self._com_index = argument + 0x1000
+ self._com_index = argument + 0x1000
self.name = argsl.pop(0)
if argsl:
self.paramflags = argsl.pop(0)
@@ -281,6 +279,7 @@
except SystemExit as e:
handle_system_exit(e)
raise
+
return f
def __call__(self, *args, **kwargs):
@@ -317,7 +316,7 @@
except:
exc_info = sys.exc_info()
traceback.print_tb(exc_info[2], file=sys.stderr)
- print >>sys.stderr, "%s: %s" % (exc_info[0].__name__,
exc_info[1])
+ print >> sys.stderr, "%s: %s" % (exc_info[0].__name__,
exc_info[1])
return 0
if self._restype_ is not None:
return res
@@ -328,7 +327,7 @@
# really slow". Now we don't worry that much about slowness
# of ctypes, and it's strange to get warnings for perfectly-
# legal code.
- #warnings.warn('C function without declared arguments called',
+ # warnings.warn('C function without declared arguments called',
# RuntimeWarning, stacklevel=2)
argtypes = []
@@ -337,7 +336,7 @@
if not args:
raise ValueError(
"native COM method call without 'this' parameter"
- )
+ )
thisvalue = args[0]
thisarg = cast(thisvalue, POINTER(POINTER(c_void_p)))
keepalives, newargs, argtypes, outargs, errcheckargs = (
@@ -366,7 +365,6 @@
return tuple(outargs)
def _call_funcptr(self, funcptr, *newargs):
-
if self._flags_ & _rawffi.FUNCFLAG_USE_ERRNO:
tmp = _rawffi.get_errno()
_rawffi.set_errno(get_errno())
@@ -431,7 +429,7 @@
ffiargs = [argtype.get_ffi_argtype() for argtype in argtypes]
ffires = restype.get_ffi_argtype()
return _ffi.FuncPtr.fromaddr(ptr, '', ffiargs, ffires,
self._flags_)
-
+
cdll = self.dll._handle
try:
ffi_argtypes = [argtype.get_ffi_argtype() for argtype in argtypes]
@@ -450,7 +448,7 @@
# funcname -> _funcname@<n>
# where n is 0, 4, 8, 12, ..., 128
for i in range(33):
- mangled_name = "_%s@%d" % (self.name, i*4)
+ mangled_name = "_%s@%d" % (self.name, i * 4)
try:
return cdll.getfunc(mangled_name,
ffi_argtypes, ffi_restype,
@@ -492,7 +490,7 @@
for argtype, arg in zip(argtypes, args):
param = argtype.from_param(arg)
_type_ = getattr(argtype, '_type_', None)
- if _type_ == 'P': # special-case for c_void_p
+ if _type_ == 'P': # special-case for c_void_p
param = param._get_buffer_value()
elif self._is_primitive(argtype):
param = param.value
@@ -668,69 +666,11 @@
self._needs_free = False
-def make_fastpath_subclass(CFuncPtr):
- if CFuncPtr._is_fastpath:
- return CFuncPtr
- #
- try:
- return make_fastpath_subclass.memo[CFuncPtr]
- except KeyError:
- pass
-
- class CFuncPtrFast(CFuncPtr):
-
- _is_fastpath = True
- _slowpath_allowed = True # set to False by tests
-
- @classmethod
- def enable_fastpath_maybe(cls, obj):
- if (obj.callable is None and
- obj._com_index is None):
- obj.__class__ = cls
-
- def __rollback(self):
- assert self._slowpath_allowed
- self.__class__ = CFuncPtr
-
- # disable the fast path if we reset argtypes
- def _setargtypes(self, argtypes):
- self.__rollback()
- self._setargtypes(argtypes)
- argtypes = property(CFuncPtr._getargtypes, _setargtypes)
-
- def _setcallable(self, func):
- self.__rollback()
- self.callable = func
- callable = property(lambda x: None, _setcallable)
-
- def _setcom_index(self, idx):
- self.__rollback()
- self._com_index = idx
- _com_index = property(lambda x: None, _setcom_index)
-
- def __call__(self, *args):
- thisarg = None
- argtypes = self._argtypes_
- restype = self._restype_
- funcptr = self._getfuncptr(argtypes, restype, thisarg)
- try:
- result = self._call_funcptr(funcptr, *args)
- result, _ = self._do_errcheck(result, args)
- except (TypeError, ArgumentError, UnicodeDecodeError):
- assert self._slowpath_allowed
- return CFuncPtr.__call__(self, *args)
- return result
-
- make_fastpath_subclass.memo[CFuncPtr] = CFuncPtrFast
- return CFuncPtrFast
-make_fastpath_subclass.memo = {}
-
-
def handle_system_exit(e):
# issue #1194: if we get SystemExit here, then exit the interpreter.
# Highly obscure imho but some people seem to depend on it.
if sys.flags.inspect:
- return # Don't exit if -i flag was given.
+ return # Don't exit if -i flag was given.
else:
code = e.code
if isinstance(code, int):
diff --git a/lib_pypy/_ctypes/structure.py b/lib_pypy/_ctypes/structure.py
--- a/lib_pypy/_ctypes/structure.py
+++ b/lib_pypy/_ctypes/structure.py
@@ -234,6 +234,9 @@
if ('_abstract_' in cls.__dict__ or cls is Structure
or cls is union.Union):
raise TypeError("abstract class")
+ if hasattr(cls, '_swappedbytes_'):
+ raise NotImplementedError("missing in PyPy: structure/union with "
+ "swapped (non-native) byte ordering")
if hasattr(cls, '_ffistruct_'):
self.__dict__['_buffer'] = self._ffistruct_(autofree=True)
return self
diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py
--- a/lib_pypy/_curses.py
+++ b/lib_pypy/_curses.py
@@ -8,6 +8,9 @@
from _curses_cffi import ffi, lib
+version = b"2.2"
+__version__ = b"2.2"
+
def _copy_to_globals(name):
globals()[name] = getattr(lib, name)
@@ -60,10 +63,6 @@
_setup()
-# Do we want this?
-# version = "2.2"
-# __version__ = "2.2"
-
# ____________________________________________________________
@@ -913,101 +912,29 @@
return None
-# XXX: Do something about the following?
-# /* Internal helper used for updating curses.LINES, curses.COLS, _curses.LINES
-# * and _curses.COLS */
-# #if defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM)
-# static int
-# update_lines_cols(void)
-# {
-# PyObject *o;
-# PyObject *m = PyImport_ImportModuleNoBlock("curses");
+# Internal helper used for updating curses.LINES, curses.COLS, _curses.LINES
+# and _curses.COLS
+def update_lines_cols():
+ globals()["LINES"] = lib.LINES
+ globals()["COLS"] = lib.COLS
+ try:
+ m = sys.modules["curses"]
+ m.LINES = lib.LINES
+ m.COLS = lib.COLS
+ except (KeyError, AttributeError):
+ pass
-# if (!m)
-# return 0;
-# o = PyInt_FromLong(LINES);
-# if (!o) {
-# Py_DECREF(m);
-# return 0;
-# }
-# if (PyObject_SetAttrString(m, "LINES", o)) {
-# Py_DECREF(m);
-# Py_DECREF(o);
-# return 0;
-# }
-# if (PyDict_SetItemString(ModDict, "LINES", o)) {
-# Py_DECREF(m);
-# Py_DECREF(o);
-# return 0;
-# }
-# Py_DECREF(o);
-# o = PyInt_FromLong(COLS);
-# if (!o) {
-# Py_DECREF(m);
-# return 0;
-# }
-# if (PyObject_SetAttrString(m, "COLS", o)) {
-# Py_DECREF(m);
-# Py_DECREF(o);
-# return 0;
-# }
-# if (PyDict_SetItemString(ModDict, "COLS", o)) {
-# Py_DECREF(m);
-# Py_DECREF(o);
-# return 0;
-# }
-# Py_DECREF(o);
-# Py_DECREF(m);
-# return 1;
-# }
-# #endif
+def resizeterm(lines, columns):
+ _ensure_initialised()
+ _check_ERR(lib.resizeterm(lines, columns), "resizeterm")
+ update_lines_cols()
-# #ifdef HAVE_CURSES_RESIZETERM
-# static PyObject *
-# PyCurses_ResizeTerm(PyObject *self, PyObject *args)
-# {
-# int lines;
-# int columns;
-# PyObject *result;
-# PyCursesInitialised;
-
-# if (!PyArg_ParseTuple(args,"ii:resizeterm", &lines, &columns))
-# return NULL;
-
-# result = PyCursesCheckERR(resizeterm(lines, columns), "resizeterm");
-# if (!result)
-# return NULL;
-# if (!update_lines_cols())
-# return NULL;
-# return result;
-# }
-
-# #endif
-
-# #ifdef HAVE_CURSES_RESIZE_TERM
-# static PyObject *
-# PyCurses_Resize_Term(PyObject *self, PyObject *args)
-# {
-# int lines;
-# int columns;
-
-# PyObject *result;
-
-# PyCursesInitialised;
-
-# if (!PyArg_ParseTuple(args,"ii:resize_term", &lines, &columns))
-# return NULL;
-
-# result = PyCursesCheckERR(resize_term(lines, columns), "resize_term");
-# if (!result)
-# return NULL;
-# if (!update_lines_cols())
-# return NULL;
-# return result;
-# }
-# #endif /* HAVE_CURSES_RESIZE_TERM */
+def resize_term(lines, columns):
+ _ensure_initialised()
+ _check_ERR(lib.resize_term(lines, columns), "resize_term")
+ update_lines_cols()
def setsyx(y, x):
diff --git a/lib_pypy/_curses_build.py b/lib_pypy/_curses_build.py
--- a/lib_pypy/_curses_build.py
+++ b/lib_pypy/_curses_build.py
@@ -87,6 +87,13 @@
static const chtype A_CHARTEXT;
static const chtype A_COLOR;
+static const chtype A_HORIZONTAL;
+static const chtype A_LEFT;
+static const chtype A_LOW;
+static const chtype A_RIGHT;
+static const chtype A_TOP;
+static const chtype A_VERTICAL;
+
static const int BUTTON1_RELEASED;
static const int BUTTON1_PRESSED;
static const int BUTTON1_CLICKED;
@@ -202,6 +209,8 @@
int resetty(void);
int reset_prog_mode(void);
int reset_shell_mode(void);
+int resizeterm(int, int);
+int resize_term(int, int);
int savetty(void);
int scroll(WINDOW *);
int scrollok(WINDOW *, bool);
diff --git a/lib_pypy/_pypy_winbase_build.py b/lib_pypy/_pypy_winbase_build.py
--- a/lib_pypy/_pypy_winbase_build.py
+++ b/lib_pypy/_pypy_winbase_build.py
@@ -79,10 +79,20 @@
BOOL WINAPI CreateProcessA(char *, char *, void *,
void *, BOOL, DWORD, char *,
char *, LPSTARTUPINFO, LPPROCESS_INFORMATION);
+BOOL WINAPI CreateProcessW(wchar_t *, wchar_t *, void *,
+ void *, BOOL, DWORD, wchar_t *,
+ wchar_t *, LPSTARTUPINFO, LPPROCESS_INFORMATION);
DWORD WINAPI WaitForSingleObject(HANDLE, DWORD);
BOOL WINAPI GetExitCodeProcess(HANDLE, LPDWORD);
BOOL WINAPI TerminateProcess(HANDLE, UINT);
HANDLE WINAPI GetStdHandle(DWORD);
+DWORD WINAPI GetModuleFileNameW(HANDLE, wchar_t *, DWORD);
+
+UINT WINAPI SetErrorMode(UINT);
+#define SEM_FAILCRITICALERRORS 0x0001
+#define SEM_NOGPFAULTERRORBOX 0x0002
+#define SEM_NOALIGNMENTFAULTEXCEPT 0x0004
+#define SEM_NOOPENFILEERRORBOX 0x8000
""")
# --------------------
diff --git a/lib_pypy/_pypy_winbase_cffi.py b/lib_pypy/_pypy_winbase_cffi.py
--- a/lib_pypy/_pypy_winbase_cffi.py
+++ b/lib_pypy/_pypy_winbase_cffi.py
@@ -3,8 +3,8 @@
ffi = _cffi_backend.FFI('_pypy_winbase_cffi',
_version = 0x2601,
- _types =
b'\x00\x00\x01\x0D\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x07\x01\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x07\x01\x00\x00\x07\x01\x00\x00\x09\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x19\x01\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x50\x03\x00\x00\x13\x11\x00\x00\x53\x03\x00\x00\x15\x11\x00\x00\x07\x01\x00\x00\x0A\x01\x00\x00\x13\x11\x00\x00\x13\x11\x00\x00\x4F\x03\x00\x00\x4E\x03\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x03\x00\x00\x1F\x11\x00\x00\x15\x11\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x08\x01\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x18\x03\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x15\x11\x00\x00\x15\x11\x00\x00\x1F\x11\x00\x00\x0A\x01\x00\x00\x07\x01\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x0D\x0D\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x18\x0D\x00\x00\x15\x11\x00\x
00\x0A\x01\x00\x00\x02\x0F\x00\x00\x18\x0D\x00\x00\x02\x0F\x00\x00\x42\x0D\x00\x00\x06\x01\x00\x00\x00\x0F\x00\x00\x42\x0D\x00\x00\x00\x0F\x00\x00\x42\x0D\x00\x00\x10\x01\x00\x00\x00\x0F\x00\x00\x15\x0D\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x15\x0D\x00\x00\x02\x0F\x00\x00\x00\x09\x00\x00\x01\x09\x00\x00\x02\x01\x00\x00\x52\x03\x00\x00\x04\x01\x00\x00\x00\x01',
- _globals =
(b'\x00\x00\x24\x23CloseHandle',0,b'\x00\x00\x1E\x23CreatePipe',0,b'\x00\x00\x12\x23CreateProcessA',0,b'\x00\x00\x2F\x23DuplicateHandle',0,b'\x00\x00\x4C\x23GetCurrentProcess',0,b'\x00\x00\x2B\x23GetExitCodeProcess',0,b'\x00\x00\x49\x23GetStdHandle',0,b'\x00\x00\x3F\x23GetVersion',0,b'\x00\x00\x27\x23TerminateProcess',0,b'\x00\x00\x3B\x23WaitForSingleObject',0,b'\x00\x00\x38\x23_get_osfhandle',0,b'\x00\x00\x10\x23_getch',0,b'\x00\x00\x10\x23_getche',0,b'\x00\x00\x44\x23_getwch',0,b'\x00\x00\x44\x23_getwche',0,b'\x00\x00\x10\x23_kbhit',0,b'\x00\x00\x07\x23_locking',0,b'\x00\x00\x0C\x23_open_osfhandle',0,b'\x00\x00\x00\x23_putch',0,b'\x00\x00\x46\x23_putwch',0,b'\x00\x00\x03\x23_setmode',0,b'\x00\x00\x00\x23_ungetch',0,b'\x00\x00\x41\x23_ungetwch',0),
- _struct_unions =
((b'\x00\x00\x00\x4E\x00\x00\x00\x02$PROCESS_INFORMATION',b'\x00\x00\x15\x11hProcess',b'\x00\x00\x15\x11hThread',b'\x00\x00\x18\x11dwProcessId',b'\x00\x00\x18\x11dwThreadId'),(b'\x00\x00\x00\x4F\x00\x00\x00\x02$STARTUPINFO',b'\x00\x00\x18\x11cb',b'\x00\x00\x13\x11lpReserved',b'\x00\x00\x13\x11lpDesktop',b'\x00\x00\x13\x11lpTitle',b'\x00\x00\x18\x11dwX',b'\x00\x00\x18\x11dwY',b'\x00\x00\x18\x11dwXSize',b'\x00\x00\x18\x11dwYSize',b'\x00\x00\x18\x11dwXCountChars',b'\x00\x00\x18\x11dwYCountChars',b'\x00\x00\x18\x11dwFillAttribute',b'\x00\x00\x18\x11dwFlags',b'\x00\x00\x42\x11wShowWindow',b'\x00\x00\x42\x11cbReserved2',b'\x00\x00\x51\x11lpReserved2',b'\x00\x00\x15\x11hStdInput',b'\x00\x00\x15\x11hStdOutput',b'\x00\x00\x15\x11hStdError')),
- _typenames =
(b'\x00\x00\x00\x1CLPPROCESS_INFORMATION',b'\x00\x00\x00\x1BLPSTARTUPINFO',b'\x00\x00\x00\x4EPROCESS_INFORMATION',b'\x00\x00\x00\x4FSTARTUPINFO',b'\x00\x00\x00\x42wint_t'),
+ _types =
b'\x00\x00\x01\x0D\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x07\x01\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x07\x01\x00\x00\x07\x01\x00\x00\x09\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x19\x01\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x64\x03\x00\x00\x13\x11\x00\x00\x67\x03\x00\x00\x15\x11\x00\x00\x07\x01\x00\x00\x0A\x01\x00\x00\x13\x11\x00\x00\x13\x11\x00\x00\x63\x03\x00\x00\x62\x03\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x03\x00\x00\x1F\x11\x00\x00\x15\x11\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x08\x01\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x18\x03\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x15\x11\x00\x00\x15\x11\x00\x00\x1F\x11\x00\x00\x0A\x01\x00\x00\x07\x01\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x5B\x03\x00\x00\x39\x11\x00\x00\x15\x11\x00\x00\x15\x11\x00\x
00\x07\x01\x00\x00\x0A\x01\x00\x00\x39\x11\x00\x00\x39\x11\x00\x00\x1B\x11\x00\x00\x1C\x11\x00\x00\x02\x0F\x00\x00\x0D\x0D\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x29\x0D\x00\x00\x08\x01\x00\x00\x02\x0F\x00\x00\x18\x0D\x00\x00\x15\x11\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x18\x0D\x00\x00\x15\x11\x00\x00\x39\x11\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x18\x0D\x00\x00\x02\x0F\x00\x00\x56\x0D\x00\x00\x06\x01\x00\x00\x00\x0F\x00\x00\x56\x0D\x00\x00\x00\x0F\x00\x00\x56\x0D\x00\x00\x10\x01\x00\x00\x00\x0F\x00\x00\x15\x0D\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x15\x0D\x00\x00\x02\x0F\x00\x00\x00\x09\x00\x00\x01\x09\x00\x00\x02\x01\x00\x00\x66\x03\x00\x00\x04\x01\x00\x00\x00\x01',
+ _globals =
(b'\x00\x00\x24\x23CloseHandle',0,b'\x00\x00\x1E\x23CreatePipe',0,b'\x00\x00\x12\x23CreateProcessA',0,b'\x00\x00\x38\x23CreateProcessW',0,b'\x00\x00\x2F\x23DuplicateHandle',0,b'\x00\x00\x60\x23GetCurrentProcess',0,b'\x00\x00\x2B\x23GetExitCodeProcess',0,b'\x00\x00\x4E\x23GetModuleFileNameW',0,b'\x00\x00\x5D\x23GetStdHandle',0,b'\x00\x00\x53\x23GetVersion',0,b'\xFF\xFF\xFF\x1FSEM_FAILCRITICALERRORS',1,b'\xFF\xFF\xFF\x1FSEM_NOALIGNMENTFAULTEXCEPT',4,b'\xFF\xFF\xFF\x1FSEM_NOGPFAULTERRORBOX',2,b'\xFF\xFF\xFF\x1FSEM_NOOPENFILEERRORBOX',32768,b'\x00\x00\x47\x23SetErrorMode',0,b'\x00\x00\x27\x23TerminateProcess',0,b'\x00\x00\x4A\x23WaitForSingleObject',0,b'\x00\x00\x44\x23_get_osfhandle',0,b'\x00\x00\x10\x23_getch',0,b'\x00\x00\x10\x23_getche',0,b'\x00\x00\x58\x23_getwch',0,b'\x00\x00\x58\x23_getwche',0,b'\x00\x00\x10\x23_kbhit',0,b'\x00\x00\x07\x23_locking',0,b'\x00\x00\x0C\x23_open_osfhandle',0,b'\x00\x00\x00\x23_putch',0,b'\x00\x00\x5A\x23_putwch',0,b'\x00\x00\x03\x23_set
mode',0,b'\x00\x00\x00\x23_ungetch',0,b'\x00\x00\x55\x23_ungetwch',0),
+ _struct_unions =
((b'\x00\x00\x00\x62\x00\x00\x00\x02$PROCESS_INFORMATION',b'\x00\x00\x15\x11hProcess',b'\x00\x00\x15\x11hThread',b'\x00\x00\x18\x11dwProcessId',b'\x00\x00\x18\x11dwThreadId'),(b'\x00\x00\x00\x63\x00\x00\x00\x02$STARTUPINFO',b'\x00\x00\x18\x11cb',b'\x00\x00\x13\x11lpReserved',b'\x00\x00\x13\x11lpDesktop',b'\x00\x00\x13\x11lpTitle',b'\x00\x00\x18\x11dwX',b'\x00\x00\x18\x11dwY',b'\x00\x00\x18\x11dwXSize',b'\x00\x00\x18\x11dwYSize',b'\x00\x00\x18\x11dwXCountChars',b'\x00\x00\x18\x11dwYCountChars',b'\x00\x00\x18\x11dwFillAttribute',b'\x00\x00\x18\x11dwFlags',b'\x00\x00\x56\x11wShowWindow',b'\x00\x00\x56\x11cbReserved2',b'\x00\x00\x65\x11lpReserved2',b'\x00\x00\x15\x11hStdInput',b'\x00\x00\x15\x11hStdOutput',b'\x00\x00\x15\x11hStdError')),
+ _typenames =
(b'\x00\x00\x00\x1CLPPROCESS_INFORMATION',b'\x00\x00\x00\x1BLPSTARTUPINFO',b'\x00\x00\x00\x62PROCESS_INFORMATION',b'\x00\x00\x00\x63STARTUPINFO',b'\x00\x00\x00\x56wint_t'),
)
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -31,10 +31,11 @@
import weakref
from threading import _get_ident as _thread_get_ident
try:
- from __pypy__ import newlist_hint
+ from __pypy__ import newlist_hint, add_memory_pressure
except ImportError:
assert '__pypy__' not in sys.builtin_module_names
newlist_hint = lambda sizehint: []
+ add_memory_pressure = lambda size: None
if sys.version_info[0] >= 3:
StandardError = Exception
@@ -150,6 +151,9 @@
def connect(database, timeout=5.0, detect_types=0, isolation_level="",
check_same_thread=True, factory=None, cached_statements=100):
factory = Connection if not factory else factory
+ # an sqlite3 db seems to be around 100 KiB at least (doesn't matter if
+ # backed by :memory: or a file)
+ add_memory_pressure(100 * 1024)
return factory(database, timeout, detect_types, isolation_level,
check_same_thread, factory, cached_statements)
diff --git a/lib_pypy/cPickle.py b/lib_pypy/cPickle.py
--- a/lib_pypy/cPickle.py
+++ b/lib_pypy/cPickle.py
@@ -431,7 +431,14 @@
self.append(obj)
def find_class(self, module, name):
- # Subclasses may override this
+ if self.find_global is None:
+ raise UnpicklingError(
+ "Global and instance pickles are not supported.")
+ return self.find_global(module, name)
+
+ def find_global(self, module, name):
+ # This can officially be patched directly in the Unpickler
+ # instance, according to the docs
__import__(module)
mod = sys.modules[module]
klass = getattr(mod, name)
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.10.0
+Version: 1.11.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.10.0"
-__version_info__ = (1, 10, 0)
+__version__ = "1.11.0"
+__version_info__ = (1, 11, 0)
# The verifier module file names are based on the CRC32 of a string that
# contains the following version number. It may be older than __version__
diff --git a/lib_pypy/cffi/_cffi_errors.h b/lib_pypy/cffi/_cffi_errors.h
new file mode 100644
--- /dev/null
+++ b/lib_pypy/cffi/_cffi_errors.h
@@ -0,0 +1,145 @@
+#ifndef CFFI_MESSAGEBOX
+# ifdef _MSC_VER
+# define CFFI_MESSAGEBOX 1
+# else
+# define CFFI_MESSAGEBOX 0
+# endif
+#endif
+
+
+#if CFFI_MESSAGEBOX
+/* Windows only: logic to take the Python-CFFI embedding logic
+ initialization errors and display them in a background thread
+ with MessageBox. The idea is that if the whole program closes
+ as a result of this problem, then likely it is already a console
+ program and you can read the stderr output in the console too.
+ If it is not a console program, then it will likely show its own
+ dialog to complain, or generally not abruptly close, and for this
+ case the background thread should stay alive.
+*/
+static void *volatile _cffi_bootstrap_text;
+
+static PyObject *_cffi_start_error_capture(void)
+{
+ PyObject *result = NULL;
+ PyObject *x, *m, *bi;
+
+ if (InterlockedCompareExchangePointer(&_cffi_bootstrap_text,
+ (void *)1, NULL) != NULL)
+ return (PyObject *)1;
+
+ m = PyImport_AddModule("_cffi_error_capture");
+ if (m == NULL)
+ goto error;
+
+ result = PyModule_GetDict(m);
+ if (result == NULL)
+ goto error;
+
+#if PY_MAJOR_VERSION >= 3
+ bi = PyImport_ImportModule("builtins");
+#else
+ bi = PyImport_ImportModule("__builtin__");
+#endif
+ if (bi == NULL)
+ goto error;
+ PyDict_SetItemString(result, "__builtins__", bi);
+ Py_DECREF(bi);
+
+ x = PyRun_String(
+ "import sys\n"
+ "class FileLike:\n"
+ " def write(self, x):\n"
+ " of.write(x)\n"
+ " self.buf += x\n"
+ "fl = FileLike()\n"
+ "fl.buf = ''\n"
+ "of = sys.stderr\n"
+ "sys.stderr = fl\n"
+ "def done():\n"
+ " sys.stderr = of\n"
+ " return fl.buf\n", /* make sure the returned value stays alive */
+ Py_file_input,
+ result, result);
+ Py_XDECREF(x);
+
+ error:
+ if (PyErr_Occurred())
+ {
+ PyErr_WriteUnraisable(Py_None);
+ PyErr_Clear();
+ }
+ return result;
+}
+
+#pragma comment(lib, "user32.lib")
+
+static DWORD WINAPI _cffi_bootstrap_dialog(LPVOID ignored)
+{
+ Sleep(666); /* may be interrupted if the whole process is closing */
+#if PY_MAJOR_VERSION >= 3
+ MessageBoxW(NULL, (wchar_t *)_cffi_bootstrap_text,
+ L"Python-CFFI error",
+ MB_OK | MB_ICONERROR);
+#else
+ MessageBoxA(NULL, (char *)_cffi_bootstrap_text,
+ "Python-CFFI error",
+ MB_OK | MB_ICONERROR);
+#endif
+ _cffi_bootstrap_text = NULL;
+ return 0;
+}
+
+static void _cffi_stop_error_capture(PyObject *ecap)
+{
+ PyObject *s;
+ void *text;
+
+ if (ecap == (PyObject *)1)
+ return;
+
+ if (ecap == NULL)
+ goto error;
+
+ s = PyRun_String("done()", Py_eval_input, ecap, ecap);
+ if (s == NULL)
+ goto error;
+
+ /* Show a dialog box, but in a background thread, and
+ never show multiple dialog boxes at once. */
+#if PY_MAJOR_VERSION >= 3
+ text = PyUnicode_AsWideCharString(s, NULL);
+#else
+ text = PyString_AsString(s);
+#endif
+
+ _cffi_bootstrap_text = text;
+
+ if (text != NULL)
+ {
+ HANDLE h;
+ h = CreateThread(NULL, 0, _cffi_bootstrap_dialog,
+ NULL, 0, NULL);
+ if (h != NULL)
+ CloseHandle(h);
+ }
+ /* decref the string, but it should stay alive as 'fl.buf'
+ in the small module above. It will really be freed only if
+ we later get another similar error. So it's a leak of at
+ most one copy of the small module. That's fine for this
+ situation which is usually a "fatal error" anyway. */
+ Py_DECREF(s);
+ PyErr_Clear();
+ return;
+
+ error:
+ _cffi_bootstrap_text = NULL;
+ PyErr_Clear();
+}
+
+#else
+
+static PyObject *_cffi_start_error_capture(void) { return NULL; }
+static void _cffi_stop_error_capture(PyObject *ecap) { }
+
+#endif
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,7 +8,7 @@
the same works for the other two macros. Py_DEBUG implies them,
but not the other way around.
*/
-#ifndef _CFFI_USE_EMBEDDING
+#if !defined(_CFFI_USE_EMBEDDING) && !defined(Py_LIMITED_API)
# include <pyconfig.h>
# if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG)
# define Py_LIMITED_API
@@ -159,9 +159,9 @@
#define _cffi_from_c_struct \
((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[18])
#define _cffi_to_c_wchar_t \
- ((wchar_t(*)(PyObject *))_cffi_exports[19])
+ ((_cffi_wchar_t(*)(PyObject *))_cffi_exports[19])
#define _cffi_from_c_wchar_t \
- ((PyObject *(*)(wchar_t))_cffi_exports[20])
+ ((PyObject *(*)(_cffi_wchar_t))_cffi_exports[20])
#define _cffi_to_c_long_double \
((long double(*)(PyObject *))_cffi_exports[21])
#define _cffi_to_c__Bool \
@@ -174,7 +174,11 @@
#define _CFFI_CPIDX 25
#define _cffi_call_python \
((void(*)(struct _cffi_externpy_s *, char *))_cffi_exports[_CFFI_CPIDX])
-#define _CFFI_NUM_EXPORTS 26
+#define _cffi_to_c_wchar3216_t \
+ ((int(*)(PyObject *))_cffi_exports[26])
+#define _cffi_from_c_wchar3216_t \
+ ((PyObject *(*)(int))_cffi_exports[27])
+#define _CFFI_NUM_EXPORTS 28
struct _cffi_ctypedescr;
@@ -215,6 +219,46 @@
return NULL;
}
+
+#ifdef HAVE_WCHAR_H
+typedef wchar_t _cffi_wchar_t;
+#else
+typedef uint16_t _cffi_wchar_t; /* same random pick as _cffi_backend.c */
+#endif
+
+_CFFI_UNUSED_FN static uint16_t _cffi_to_c_char16_t(PyObject *o)
+{
+ if (sizeof(_cffi_wchar_t) == 2)
+ return (uint16_t)_cffi_to_c_wchar_t(o);
+ else
+ return (uint16_t)_cffi_to_c_wchar3216_t(o);
+}
+
+_CFFI_UNUSED_FN static PyObject *_cffi_from_c_char16_t(uint16_t x)
+{
+ if (sizeof(_cffi_wchar_t) == 2)
+ return _cffi_from_c_wchar_t(x);
+ else
+ return _cffi_from_c_wchar3216_t(x);
+}
+
+_CFFI_UNUSED_FN static int _cffi_to_c_char32_t(PyObject *o)
+{
+ if (sizeof(_cffi_wchar_t) == 4)
+ return (int)_cffi_to_c_wchar_t(o);
+ else
+ return (int)_cffi_to_c_wchar3216_t(o);
+}
+
+_CFFI_UNUSED_FN static PyObject *_cffi_from_c_char32_t(int x)
+{
+ if (sizeof(_cffi_wchar_t) == 4)
+ return _cffi_from_c_wchar_t(x);
+ else
+ return _cffi_from_c_wchar3216_t(x);
+}
+
+
/********** end CPython-specific section **********/
#else
_CFFI_UNUSED_FN
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
@@ -109,6 +109,8 @@
/********** CPython-specific section **********/
#ifndef PYPY_VERSION
+#include "_cffi_errors.h"
+
#define _cffi_call_python_org _cffi_exports[_CFFI_CPIDX]
@@ -220,8 +222,16 @@
/* Print as much information as potentially useful.
Debugging load-time failures with embedding is not fun
*/
+ PyObject *ecap;
PyObject *exception, *v, *tb, *f, *modules, *mod;
PyErr_Fetch(&exception, &v, &tb);
+ ecap = _cffi_start_error_capture();
+ f = PySys_GetObject((char *)"stderr");
+ if (f != NULL && f != Py_None) {
+ PyFile_WriteString(
+ "Failed to initialize the Python-CFFI embedding logic:\n\n",
f);
+ }
+
if (exception != NULL) {
PyErr_NormalizeException(&exception, &v, &tb);
PyErr_Display(exception, v, tb);
@@ -230,10 +240,9 @@
Py_XDECREF(v);
Py_XDECREF(tb);
- f = PySys_GetObject((char *)"stderr");
if (f != NULL && f != Py_None) {
PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME
- "\ncompiled with cffi version: 1.10.0"
+ "\ncompiled with cffi version: 1.11.0"
"\n_cffi_backend module: ", f);
modules = PyImport_GetModuleDict();
mod = PyDict_GetItemString(modules, "_cffi_backend");
@@ -249,6 +258,7 @@
PyFile_WriteObject(PySys_GetObject((char *)"path"), f, 0);
PyFile_WriteString("\n\n", f);
}
+ _cffi_stop_error_capture(ecap);
}
result = -1;
goto done;
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
@@ -75,9 +75,10 @@
self._init_once_cache = {}
self._cdef_version = None
self._embedding = None
+ self._typecache = model.get_typecache(backend)
if hasattr(backend, 'set_ffi'):
backend.set_ffi(self)
- for name in backend.__dict__:
+ for name in list(backend.__dict__):
if name.startswith('RTLD_'):
setattr(self, name, getattr(backend, name))
#
@@ -764,7 +765,7 @@
if sys.platform != "win32":
return backend.load_library(None, flags)
name = "c" # Windows: load_library(None) fails, but this works
- # (backward compatibility hack only)
+ # on Python 2 (backward compatibility hack only)
first_error = None
if '.' in name or '/' in name or os.sep in name:
try:
@@ -774,6 +775,9 @@
import ctypes.util
path = ctypes.util.find_library(name)
if path is None:
+ if name == "c" and sys.platform == "win32" and sys.version_info >=
(3,):
+ raise OSError("dlopen(None) cannot work on Windows for Python 3 "
+ "(see http://bugs.python.org/issue23606)")
msg = ("ctypes.util.find_library() did not manage "
"to locate a library called %r" % (name,))
if first_error is not None:
diff --git a/lib_pypy/cffi/cffi_opcode.py b/lib_pypy/cffi/cffi_opcode.py
--- a/lib_pypy/cffi/cffi_opcode.py
+++ b/lib_pypy/cffi/cffi_opcode.py
@@ -105,8 +105,12 @@
PRIM_UINT_FAST64 = 45
PRIM_INTMAX = 46
PRIM_UINTMAX = 47
+PRIM_FLOATCOMPLEX = 48
+PRIM_DOUBLECOMPLEX = 49
+PRIM_CHAR16 = 50
+PRIM_CHAR32 = 51
-_NUM_PRIM = 48
+_NUM_PRIM = 52
_UNKNOWN_PRIM = -1
_UNKNOWN_FLOAT_PRIM = -2
_UNKNOWN_LONG_DOUBLE = -3
@@ -128,8 +132,12 @@
'float': PRIM_FLOAT,
'double': PRIM_DOUBLE,
'long double': PRIM_LONGDOUBLE,
+ 'float _Complex': PRIM_FLOATCOMPLEX,
+ 'double _Complex': PRIM_DOUBLECOMPLEX,
'_Bool': PRIM_BOOL,
'wchar_t': PRIM_WCHAR,
+ 'char16_t': PRIM_CHAR16,
+ 'char32_t': PRIM_CHAR32,
'int8_t': PRIM_INT8,
'uint8_t': PRIM_UINT8,
'int16_t': PRIM_INT16,
diff --git a/lib_pypy/cffi/cparser.py b/lib_pypy/cffi/cparser.py
--- a/lib_pypy/cffi/cparser.py
+++ b/lib_pypy/cffi/cparser.py
@@ -16,6 +16,7 @@
except ImportError:
lock = None
+CDEF_SOURCE_STRING = "<cdef source string>"
_r_comment = re.compile(r"/\*.*?\*/|//([^\n\\]|\\.)*?$",
re.DOTALL | re.MULTILINE)
_r_define = re.compile(r"^\s*#\s*define\s+([A-Za-z_][A-Za-z_0-9]*)"
@@ -258,15 +259,21 @@
ctn.discard(name)
typenames += sorted(ctn)
#
- csourcelines = ['typedef int %s;' % typename for typename in typenames]
+ csourcelines = []
+ csourcelines.append('# 1 "<cdef automatic initialization code>"')
+ for typename in typenames:
+ csourcelines.append('typedef int %s;' % typename)
csourcelines.append('typedef int __dotdotdotint__, __dotdotdotfloat__,'
' __dotdotdot__;')
+ # this forces pycparser to consider the following in the file
+ # called <cdef source string> from line 1
+ csourcelines.append('# 1 "%s"' % (CDEF_SOURCE_STRING,))
csourcelines.append(csource)
- csource = '\n'.join(csourcelines)
+ fullcsource = '\n'.join(csourcelines)
if lock is not None:
lock.acquire() # pycparser is not thread-safe...
try:
- ast = _get_parser().parse(csource)
+ ast = _get_parser().parse(fullcsource)
except pycparser.c_parser.ParseError as e:
self.convert_pycparser_error(e, csource)
finally:
@@ -276,17 +283,17 @@
return ast, macros, csource
def _convert_pycparser_error(self, e, csource):
- # xxx look for ":NUM:" at the start of str(e) and try to interpret
- # it as a line number
+ # xxx look for "<cdef source string>:NUM:" at the start of str(e)
+ # and interpret that as a line number. This will not work if
+ # the user gives explicit ``# NUM "FILE"`` directives.
line = None
msg = str(e)
- if msg.startswith(':') and ':' in msg[1:]:
- linenum = msg[1:msg.find(':',1)]
- if linenum.isdigit():
- linenum = int(linenum, 10)
- csourcelines = csource.splitlines()
- if 1 <= linenum <= len(csourcelines):
- line = csourcelines[linenum-1]
+ match = re.match(r"%s:(\d+):" % (CDEF_SOURCE_STRING,), msg)
+ if match:
+ linenum = int(match.group(1), 10)
+ csourcelines = csource.splitlines()
+ if 1 <= linenum <= len(csourcelines):
+ line = csourcelines[linenum-1]
return line
def convert_pycparser_error(self, e, csource):
@@ -321,10 +328,12 @@
break
else:
assert 0
+ current_decl = None
#
try:
self._inside_extern_python = '__cffi_extern_python_stop'
for decl in iterator:
+ current_decl = decl
if isinstance(decl, pycparser.c_ast.Decl):
self._parse_decl(decl)
elif isinstance(decl, pycparser.c_ast.Typedef):
@@ -348,7 +357,13 @@
elif decl.__class__.__name__ == 'Pragma':
pass # skip pragma, only in pycparser 2.15
else:
- raise CDefError("unrecognized construct", decl)
+ raise CDefError("unexpected <%s>: this construct is valid "
+ "C but not valid in cdef()" %
+ decl.__class__.__name__, decl)
+ except CDefError as e:
+ if len(e.args) == 1:
+ e.args = e.args + (current_decl,)
+ raise
except FFIError as e:
msg = self._convert_pycparser_error(e, csource)
if msg:
diff --git a/lib_pypy/cffi/error.py b/lib_pypy/cffi/error.py
--- a/lib_pypy/cffi/error.py
+++ b/lib_pypy/cffi/error.py
@@ -5,10 +5,13 @@
class CDefError(Exception):
def __str__(self):
try:
- line = 'line %d: ' % (self.args[1].coord.line,)
+ current_decl = self.args[1]
+ filename = current_decl.coord.file
+ linenum = current_decl.coord.line
+ prefix = '%s:%d: ' % (filename, linenum)
except (AttributeError, TypeError, IndexError):
- line = ''
- return '%s%s' % (line, self.args[0])
+ prefix = ''
+ return '%s%s' % (prefix, self.args[0])
class VerificationError(Exception):
""" An error raised when verification fails
diff --git a/lib_pypy/cffi/ffiplatform.py b/lib_pypy/cffi/ffiplatform.py
--- a/lib_pypy/cffi/ffiplatform.py
+++ b/lib_pypy/cffi/ffiplatform.py
@@ -6,6 +6,7 @@
'extra_objects', 'depends']
def get_extension(srcfilename, modname, sources=(), **kwds):
+ _hack_at_distutils()
from distutils.core import Extension
allsources = [srcfilename]
for src in sources:
@@ -15,6 +16,7 @@
def compile(tmpdir, ext, compiler_verbose=0, debug=None):
"""Compile a C extension module using distutils."""
+ _hack_at_distutils()
saved_environ = os.environ.copy()
try:
outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
@@ -113,3 +115,13 @@
f = cStringIO.StringIO()
_flatten(x, f)
return f.getvalue()
+
+def _hack_at_distutils():
+ # Windows-only workaround for some configurations: see
+ # https://bugs.python.org/issue23246 (Python 2.7 with
+ # a specific MS compiler suite download)
+ if sys.platform == "win32":
+ try:
+ import setuptools # for side-effects, patches distutils
+ except ImportError:
+ pass
diff --git a/lib_pypy/cffi/model.py b/lib_pypy/cffi/model.py
--- a/lib_pypy/cffi/model.py
+++ b/lib_pypy/cffi/model.py
@@ -95,7 +95,8 @@
class BasePrimitiveType(BaseType):
- pass
+ def is_complex_type(self):
+ return False
class PrimitiveType(BasePrimitiveType):
@@ -116,9 +117,13 @@
'float': 'f',
'double': 'f',
'long double': 'f',
+ 'float _Complex': 'j',
+ 'double _Complex': 'j',
'_Bool': 'i',
# the following types are not primitive in the C sense
'wchar_t': 'c',
+ 'char16_t': 'c',
+ 'char32_t': 'c',
'int8_t': 'i',
'uint8_t': 'i',
'int16_t': 'i',
@@ -163,6 +168,8 @@
return self.ALL_PRIMITIVE_TYPES[self.name] == 'i'
def is_float_type(self):
return self.ALL_PRIMITIVE_TYPES[self.name] == 'f'
+ def is_complex_type(self):
+ return self.ALL_PRIMITIVE_TYPES[self.name] == 'j'
def build_backend_type(self, ffi, finishlist):
return global_cache(self, ffi, 'new_primitive_type', self.name)
@@ -561,22 +568,26 @@
global_lock = allocate_lock()
+_typecache_cffi_backend = weakref.WeakValueDictionary()
+
+def get_typecache(backend):
+ # returns _typecache_cffi_backend if backend is the _cffi_backend
+ # module, or type(backend).__typecache if backend is an instance of
+ # CTypesBackend (or some FakeBackend class during tests)
+ if isinstance(backend, types.ModuleType):
+ return _typecache_cffi_backend
+ with global_lock:
+ if not hasattr(type(backend), '__typecache'):
+ type(backend).__typecache = weakref.WeakValueDictionary()
+ return type(backend).__typecache
def global_cache(srctype, ffi, funcname, *args, **kwds):
key = kwds.pop('key', (funcname, args))
assert not kwds
try:
- return ffi._backend.__typecache[key]
+ return ffi._typecache[key]
except KeyError:
pass
- except AttributeError:
- # initialize the __typecache attribute, either at the module level
- # if ffi._backend is a module, or at the class level if ffi._backend
- # is some instance.
- if isinstance(ffi._backend, types.ModuleType):
- ffi._backend.__typecache = weakref.WeakValueDictionary()
- else:
- type(ffi._backend).__typecache = weakref.WeakValueDictionary()
try:
res = getattr(ffi._backend, funcname)(*args)
except NotImplementedError as e:
@@ -584,7 +595,7 @@
# note that setdefault() on WeakValueDictionary is not atomic
# and contains a rare bug (http://bugs.python.org/issue19542);
# we have to use a lock and do it ourselves
- cache = ffi._backend.__typecache
+ cache = ffi._typecache
with global_lock:
res1 = cache.get(key)
if res1 is None:
diff --git a/lib_pypy/cffi/parse_c_type.h b/lib_pypy/cffi/parse_c_type.h
--- a/lib_pypy/cffi/parse_c_type.h
+++ b/lib_pypy/cffi/parse_c_type.h
@@ -79,8 +79,12 @@
#define _CFFI_PRIM_UINT_FAST64 45
#define _CFFI_PRIM_INTMAX 46
#define _CFFI_PRIM_UINTMAX 47
+#define _CFFI_PRIM_FLOATCOMPLEX 48
+#define _CFFI_PRIM_DOUBLECOMPLEX 49
+#define _CFFI_PRIM_CHAR16 50
+#define _CFFI_PRIM_CHAR32 51
-#define _CFFI__NUM_PRIM 48
+#define _CFFI__NUM_PRIM 52
#define _CFFI__UNKNOWN_PRIM (-1)
#define _CFFI__UNKNOWN_FLOAT_PRIM (-2)
#define _CFFI__UNKNOWN_LONG_DOUBLE (-3)
diff --git a/lib_pypy/cffi/recompiler.py b/lib_pypy/cffi/recompiler.py
--- a/lib_pypy/cffi/recompiler.py
+++ b/lib_pypy/cffi/recompiler.py
@@ -3,8 +3,9 @@
from .error import VerificationError
from .cffi_opcode import *
-VERSION = "0x2601"
-VERSION_EMBEDDED = "0x2701"
+VERSION_BASE = 0x2601
+VERSION_EMBEDDED = 0x2701
+VERSION_CHAR16CHAR32 = 0x2801
class GlobalExpr:
@@ -126,6 +127,10 @@
self.ffi = ffi
self.module_name = module_name
self.target_is_python = target_is_python
+ self._version = VERSION_BASE
+
+ def needs_version(self, ver):
+ self._version = max(self._version, ver)
def collect_type_table(self):
self._typesdict = {}
@@ -303,10 +308,10 @@
base_module_name,))
prnt('#endif')
lines = self._rel_readlines('_embedding.h')
+ i = lines.index('#include "_cffi_errors.h"\n')
+ lines[i:i+1] = self._rel_readlines('_cffi_errors.h')
prnt(''.join(lines))
- version = VERSION_EMBEDDED
- else:
- version = VERSION
+ self.needs_version(VERSION_EMBEDDED)
#
# then paste the C source given by the user, verbatim.
prnt('/************************************************************/')
@@ -405,7 +410,7 @@
prnt(' _cffi_call_python_org = '
'(void(*)(struct _cffi_externpy_s *, char *))p[1];')
prnt(' }')
- prnt(' p[0] = (const void *)%s;' % version)
+ prnt(' p[0] = (const void *)0x%x;' % self._version)
prnt(' p[1] = &_cffi_type_context;')
prnt('}')
# on Windows, distutils insists on putting init_cffi_xyz in
@@ -423,21 +428,22 @@
prnt('PyMODINIT_FUNC')
prnt('PyInit_%s(void)' % (base_module_name,))
prnt('{')
- prnt(' return _cffi_init("%s", %s, &_cffi_type_context);' % (
- self.module_name, version))
+ prnt(' return _cffi_init("%s", 0x%x, &_cffi_type_context);' % (
+ self.module_name, self._version))
prnt('}')
prnt('#else')
prnt('PyMODINIT_FUNC')
prnt('init%s(void)' % (base_module_name,))
prnt('{')
- prnt(' _cffi_init("%s", %s, &_cffi_type_context);' % (
- self.module_name, version))
+ prnt(' _cffi_init("%s", 0x%x, &_cffi_type_context);' % (
+ self.module_name, self._version))
prnt('}')
prnt('#endif')
prnt()
prnt('#ifdef __GNUC__')
prnt('# pragma GCC visibility pop')
prnt('#endif')
+ self._version = None
def _to_py(self, x):
if isinstance(x, str):
@@ -476,7 +482,8 @@
prnt('from %s import ffi as _ffi%d' % (included_module_name, i))
prnt()
prnt("ffi = _cffi_backend.FFI('%s'," % (self.module_name,))
- prnt(" _version = %s," % (VERSION,))
+ prnt(" _version = 0x%x," % (self._version,))
+ self._version = None
#
# the '_types' keyword argument
self.cffi_types = tuple(self.cffi_types) # don't change any more
@@ -506,7 +513,7 @@
def _convert_funcarg_to_c(self, tp, fromvar, tovar, errcode):
extraarg = ''
- if isinstance(tp, model.BasePrimitiveType):
+ if isinstance(tp, model.BasePrimitiveType) and not
tp.is_complex_type():
if tp.is_integer_type() and tp.name != '_Bool':
converter = '_cffi_to_c_int'
extraarg = ', %s' % tp.name
@@ -515,8 +522,11 @@
# double' here, and _cffi_to_c_double would loose precision
converter = '(%s)_cffi_to_c_double' % (tp.get_c_name(''),)
else:
- converter = '(%s)_cffi_to_c_%s' % (tp.get_c_name(''),
+ cname = tp.get_c_name('')
+ converter = '(%s)_cffi_to_c_%s' % (cname,
tp.name.replace(' ', '_'))
+ if cname in ('char16_t', 'char32_t'):
+ self.needs_version(VERSION_CHAR16CHAR32)
errvalue = '-1'
#
elif isinstance(tp, model.PointerType):
@@ -524,8 +534,10 @@
tovar, errcode)
return
#
- elif isinstance(tp, model.StructOrUnionOrEnum):
- # a struct (not a struct pointer) as a function argument
+ elif (isinstance(tp, model.StructOrUnionOrEnum) or
+ isinstance(tp, model.BasePrimitiveType)):
+ # a struct (not a struct pointer) as a function argument;
+ # or, a complex (the same code works)
self._prnt(' if (_cffi_to_c((char *)&%s, _cffi_type(%d), %s) < 0)'
% (tovar, self._gettypenum(tp), fromvar))
self._prnt(' %s;' % errcode)
@@ -570,8 +582,11 @@
return '_cffi_from_c_int(%s, %s)' % (var, tp.name)
elif isinstance(tp, model.UnknownFloatType):
return '_cffi_from_c_double(%s)' % (var,)
- elif tp.name != 'long double':
- return '_cffi_from_c_%s(%s)' % (tp.name.replace(' ', '_'), var)
+ elif tp.name != 'long double' and not tp.is_complex_type():
+ cname = tp.name.replace(' ', '_')
+ if cname in ('char16_t', 'char32_t'):
+ self.needs_version(VERSION_CHAR16CHAR32)
+ return '_cffi_from_c_%s(%s)' % (cname, var)
else:
return '_cffi_from_c_deref((char *)&%s, _cffi_type(%d))' % (
var, self._gettypenum(tp))
@@ -734,21 +749,26 @@
#
# the PyPy version: need to replace struct/union arguments with
# pointers, and if the result is a struct/union, insert a first
- # arg that is a pointer to the result.
+ # arg that is a pointer to the result. We also do that for
+ # complex args and return type.
+ def need_indirection(type):
+ return (isinstance(type, model.StructOrUnion) or
+ (isinstance(type, model.PrimitiveType) and
+ type.is_complex_type()))
difference = False
arguments = []
call_arguments = []
context = 'argument of %s' % name
for i, type in enumerate(tp.args):
indirection = ''
- if isinstance(type, model.StructOrUnion):
+ if need_indirection(type):
indirection = '*'
difference = True
arg = type.get_c_name(' %sx%d' % (indirection, i), context)
arguments.append(arg)
call_arguments.append('%sx%d' % (indirection, i))
tp_result = tp.result
- if isinstance(tp_result, model.StructOrUnion):
+ if need_indirection(tp_result):
context = 'result of %s' % name
arg = tp_result.get_c_name(' *result', context)
arguments.insert(0, arg)
@@ -1180,7 +1200,7 @@
size_of_result = '(int)sizeof(%s)' % (
tp.result.get_c_name('', context),)
prnt('static struct _cffi_externpy_s _cffi_externpy__%s =' % name)
- prnt(' { "%s", %s };' % (name, size_of_result))
+ prnt(' { "%s.%s", %s };' % (self.module_name, name, size_of_result))
prnt()
#
arguments = []
@@ -1479,6 +1499,12 @@
_patch_for_embedding(patchlist)
if target != '*':
_patch_for_target(patchlist, target)
+ if compiler_verbose:
+ if tmpdir == '.':
+ msg = 'the current directory is'
+ else:
+ msg = 'setting the current directory to'
+ print('%s %r' % (msg, os.path.abspath(tmpdir)))
os.chdir(tmpdir)
outputfilename = ffiplatform.compile('.', ext,
compiler_verbose, debug)
diff --git a/lib_pypy/cffi/vengine_cpy.py b/lib_pypy/cffi/vengine_cpy.py
--- a/lib_pypy/cffi/vengine_cpy.py
+++ b/lib_pypy/cffi/vengine_cpy.py
@@ -808,7 +808,8 @@
#include <stddef.h>
/* this block of #ifs should be kept exactly identical between
- c/_cffi_backend.c, cffi/vengine_cpy.py, cffi/vengine_gen.py */
+ c/_cffi_backend.c, cffi/vengine_cpy.py, cffi/vengine_gen.py
+ and cffi/_cffi_include.h */
#if defined(_MSC_VER)
# include <malloc.h> /* for alloca() */
# if _MSC_VER < 1600 /* MSVC < 2010 */
@@ -842,11 +843,13 @@
# include <stdint.h>
# endif
# if _MSC_VER < 1800 /* MSVC < 2013 */
- typedef unsigned char _Bool;
+# ifndef __cplusplus
+ typedef unsigned char _Bool;
+# endif
# endif
#else
# include <stdint.h>
-# if (defined (__SVR4) && defined (__sun)) || defined(_AIX)
+# if (defined (__SVR4) && defined (__sun)) || defined(_AIX) || defined(__hpux)
# include <alloca.h>
# endif
#endif
diff --git a/lib_pypy/cffi/vengine_gen.py b/lib_pypy/cffi/vengine_gen.py
--- a/lib_pypy/cffi/vengine_gen.py
+++ b/lib_pypy/cffi/vengine_gen.py
@@ -627,7 +627,8 @@
#include <sys/types.h> /* XXX for ssize_t on some platforms */
/* this block of #ifs should be kept exactly identical between
- c/_cffi_backend.c, cffi/vengine_cpy.py, cffi/vengine_gen.py */
+ c/_cffi_backend.c, cffi/vengine_cpy.py, cffi/vengine_gen.py
+ and cffi/_cffi_include.h */
#if defined(_MSC_VER)
# include <malloc.h> /* for alloca() */
# if _MSC_VER < 1600 /* MSVC < 2010 */
@@ -661,11 +662,13 @@
# include <stdint.h>
# endif
# if _MSC_VER < 1800 /* MSVC < 2013 */
- typedef unsigned char _Bool;
+# ifndef __cplusplus
+ typedef unsigned char _Bool;
+# endif
# endif
#else
# include <stdint.h>
-# if (defined (__SVR4) && defined (__sun)) || defined(_AIX)
+# if (defined (__SVR4) && defined (__sun)) || defined(_AIX) || defined(__hpux)
# include <alloca.h>
# endif
#endif
diff --git a/lib_pypy/cffi/verifier.py b/lib_pypy/cffi/verifier.py
--- a/lib_pypy/cffi/verifier.py
+++ b/lib_pypy/cffi/verifier.py
@@ -26,16 +26,6 @@
s = s.encode('ascii')
super(NativeIO, self).write(s)
-def _hack_at_distutils():
- # Windows-only workaround for some configurations: see
- # https://bugs.python.org/issue23246 (Python 2.7 with
- # a specific MS compiler suite download)
- if sys.platform == "win32":
- try:
- import setuptools # for side-effects, patches distutils
- except ImportError:
- pass
-
class Verifier(object):
@@ -126,7 +116,7 @@
return basename
def get_extension(self):
- _hack_at_distutils() # backward compatibility hack
+ ffiplatform._hack_at_distutils() # backward compatibility hack
if not self._has_source:
with self.ffi._lock:
if not self._has_source:
diff --git a/lib_pypy/stackless.py b/lib_pypy/stackless.py
--- a/lib_pypy/stackless.py
+++ b/lib_pypy/stackless.py
@@ -268,12 +268,22 @@
assert abs(d) == 1
source = getcurrent()
source.tempval = arg
- if d > 0:
- cando = self.balance < 0
- dir = d
- else:
- cando = self.balance > 0
- dir = 0
+ while True:
+ if d > 0:
+ cando = self.balance < 0
+ dir = d
+ else:
+ cando = self.balance > 0
+ dir = 0
+
+ if cando and self.queue[0]._tasklet_killed:
+ # issue #2595: the tasklet was killed while waiting.
+ # drop that tasklet from consideration and try again.
+ self.balance += d
+ self.queue.popleft()
+ else:
+ # normal path
+ break
if _channel_callback is not None:
_channel_callback(self, source, dir, not cando)
@@ -348,6 +358,8 @@
module.
"""
tempval = None
+ _tasklet_killed = False
+
def __new__(cls, func=None, label=''):
res = coroutine.__new__(cls)
res.label = label
@@ -395,6 +407,7 @@
If the exception passes the toplevel frame of the tasklet,
the tasklet will silently die.
"""
+ self._tasklet_killed = True
if not self.is_zombie:
# Killing the tasklet by throwing TaskletExit exception.
coroutine.kill(self)
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -42,8 +42,9 @@
from rpython.jit.backend import detect_cpu
try:
if detect_cpu.autodetect().startswith('x86'):
- working_modules.add('_vmprof')
- working_modules.add('faulthandler')
+ if not sys.platform.startswith('openbsd'):
+ working_modules.add('_vmprof')
+ working_modules.add('faulthandler')
except detect_cpu.ProcessorAutodetectError:
pass
@@ -219,9 +220,6 @@
BoolOption("withsmalllong", "use a version of 'long' in a C long long",
default=False),
- BoolOption("withstrbuf", "use strings optimized for addition (ver 2)",
- default=False),
-
BoolOption("withspecialisedtuple",
"use specialised tuples",
default=False),
diff --git a/pypy/doc/build.rst b/pypy/doc/build.rst
--- a/pypy/doc/build.rst
+++ b/pypy/doc/build.rst
@@ -79,6 +79,9 @@
_ssl
libssl
+_vmprof
+ libunwind (optional, loaded dynamically at runtime)
+
Make sure to have these libraries (with development headers) installed
before building PyPy, otherwise the resulting binary will not contain
these modules. Furthermore, the following libraries should be present
@@ -90,7 +93,8 @@
libsqlite3
curses
- libncurses
+ libncurses-dev (for PyPy2)
+ libncursesw-dev (for PyPy3)
gdbm
libgdbm-dev
@@ -103,12 +107,13 @@
To run untranslated tests, you need the Boehm garbage collector libgc.
-On Debian, this is the command to install all build-time dependencies::
+On Debian and Ubuntu, this is the command to install all build-time
+dependencies::
apt-get install gcc make libffi-dev pkg-config libz-dev libbz2-dev \
libsqlite3-dev libncurses-dev libexpat1-dev libssl-dev libgdbm-dev \
tk-dev libgc-dev python-cffi \
- liblzma-dev # For lzma on PyPy3.
+ liblzma-dev libncursesw-dev # these two only needed on PyPy3
On Fedora::
@@ -185,13 +190,36 @@
::
cd pypy/tool/release
- ./package.py pypy-VER-PLATFORM
+ ./package.py --archive-name=pypy-VER-PLATFORM
This creates a clean and prepared hierarchy, as well as a ``.tar.bz2``
with the same content; both are found by default in
``/tmp/usession-YOURNAME/build/``. You can then either move the file
hierarchy or unpack the ``.tar.bz2`` at the correct place.
+It is recommended to use package.py because custom scripts will
+invariably become out-of-date. If you want to write custom scripts
+anyway, note an easy-to-miss point: some modules are written with CFFI,
+and require some compilation. If you install PyPy as root without
+pre-compiling them, normal users will get errors:
+
+* PyPy 2.5.1 or earlier: normal users would see permission errors.
+ Installers need to run ``pypy -c "import gdbm"`` and other similar
+ commands at install time; the exact list is in `package.py`_. Users
+ seeing a broken installation of PyPy can fix it after-the-fact if they
+ have sudo rights, by running once e.g. ``sudo pypy -c "import gdbm``.
+
+* PyPy 2.6 and later: anyone would get ``ImportError: no module named
+ _gdbm_cffi``. Installers need to run ``pypy _gdbm_build.py`` in the
+ ``lib_pypy`` directory during the installation process (plus others;
+ see the exact list in `package.py`_). Users seeing a broken
+ installation of PyPy can fix it after-the-fact, by running ``pypy
+ /path/to/lib_pypy/_gdbm_build.py``. This command produces a file
+ called ``_gdbm_cffi.pypy-41.so`` locally, which is a C extension
+ module for PyPy. You can move it at any place where modules are
+ normally found: e.g. in your project's main directory, or in a
+ directory that you add to the env var ``PYTHONPATH``.
+
Installation
------------
diff --git a/pypy/doc/conf.py b/pypy/doc/conf.py
--- a/pypy/doc/conf.py
+++ b/pypy/doc/conf.py
@@ -59,16 +59,16 @@
# General information about the project.
project = u'PyPy'
-copyright = u'2016, The PyPy Project'
+copyright = u'2017, The PyPy Project'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
-version = '5.4'
+version = '5.8'
# The full version, including alpha/beta/rc tags.
-release = '5.4.0'
+release = '5.8.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/pypy/doc/contributor.rst b/pypy/doc/contributor.rst
--- a/pypy/doc/contributor.rst
+++ b/pypy/doc/contributor.rst
@@ -6,11 +6,11 @@
Armin Rigo
Maciej Fijalkowski
- Carl Friedrich Bolz
+ Carl Friedrich Bolz-Tereick
Amaury Forgeot d'Arc
Antonio Cuni
+ Matti Picus
Samuele Pedroni
- Matti Picus
Ronan Lamy
Alex Gaynor
Philip Jenvey
@@ -68,28 +68,28 @@
Vincent Legoll
Michael Foord
Stephan Diehl
+ Stefano Rivera
Stefan Schwarzer
Tomek Meka
Valentino Volonghi
- Stefano Rivera
Patrick Maupin
Devin Jeanpierre
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit