Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r90632:e9f7ee0d2969
Date: 2017-03-11 17:12 +0100
http://bitbucket.org/pypy/pypy/changeset/e9f7ee0d2969/
Log: hg merge default
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
@@ -570,7 +570,10 @@
# we need 'libpypy-c.{so,dylib}', which should be by
# default located in 'sys.prefix/bin' for installed
# systems.
- pythonlib = "pypy-c"
+ if sys.version_info < (3,):
+ pythonlib = "pypy-c"
+ else:
+ pythonlib = "pypy3-c"
if hasattr(sys, 'prefix'):
ensure('library_dirs', os.path.join(sys.prefix, 'bin'))
# On uninstalled pypy's, the libpypy-c is typically found in
@@ -756,21 +759,27 @@
def _load_backend_lib(backend, name, flags):
+ import os
if name is None:
if sys.platform != "win32":
return backend.load_library(None, flags)
name = "c" # Windows: load_library(None) fails, but this works
# (backward compatibility hack only)
- try:
- if '.' not in name and '/' not in name:
- raise OSError("library not found: %r" % (name,))
- return backend.load_library(name, flags)
- except OSError:
- import ctypes.util
- path = ctypes.util.find_library(name)
- if path is None:
- raise # propagate the original OSError
- return backend.load_library(path, flags)
+ first_error = None
+ if '.' in name or '/' in name or os.sep in name:
+ try:
+ return backend.load_library(name, flags)
+ except OSError as e:
+ first_error = e
+ import ctypes.util
+ path = ctypes.util.find_library(name)
+ if path is None:
+ msg = ("ctypes.util.find_library() did not manage "
+ "to locate a library called %r" % (name,))
+ if first_error is not None:
+ msg = "%s. Additionally, %s" % (first_error, msg)
+ raise OSError(msg)
+ return backend.load_library(path, flags)
def _make_ffi_library(ffi, libname, flags):
backend = ffi._backend
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
@@ -34,6 +34,9 @@
r'(Python|Python\s*\+\s*C|C\s*\+\s*Python)"\s*.')
_r_star_const_space = re.compile( # matches "* const "
r"[*]\s*((const|volatile|restrict)\b\s*)+")
+_r_int_dotdotdot = re.compile(r"(\b(int|long|short|signed|unsigned|char)\s*)+"
+ r"\.\.\.")
+_r_float_dotdotdot = re.compile(r"\b(double|float)\s*\.\.\.")
def _get_parser():
global _parser_cache
@@ -180,6 +183,10 @@
assert csource[p:p+3] == '...'
csource = '%s __dotdotdot%d__ %s' % (csource[:p], number,
csource[p+3:])
+ # Replace "int ..." or "unsigned long int..." with "__dotdotdotint__"
+ csource = _r_int_dotdotdot.sub(' __dotdotdotint__ ', csource)
+ # Replace "float ..." or "double..." with "__dotdotdotfloat__"
+ csource = _r_float_dotdotdot.sub(' __dotdotdotfloat__ ', csource)
# Replace all remaining "..." with the same name, "__dotdotdot__",
# which is declared with a typedef for the purpose of C parsing.
return csource.replace('...', ' __dotdotdot__ '), macros
@@ -252,7 +259,8 @@
typenames += sorted(ctn)
#
csourcelines = ['typedef int %s;' % typename for typename in typenames]
- csourcelines.append('typedef int __dotdotdot__;')
+ csourcelines.append('typedef int __dotdotdotint__, __dotdotdotfloat__,'
+ ' __dotdotdot__;')
csourcelines.append(csource)
csource = '\n'.join(csourcelines)
if lock is not None:
@@ -311,6 +319,8 @@
for decl in iterator:
if decl.name == '__dotdotdot__':
break
+ else:
+ assert 0
#
try:
self._inside_extern_python = '__cffi_extern_python_stop'
@@ -322,15 +332,15 @@
raise CDefError("typedef does not declare any name",
decl)
quals = 0
- if (isinstance(decl.type.type,
pycparser.c_ast.IdentifierType)
- and decl.type.type.names[-1] == '__dotdotdot__'):
+ if (isinstance(decl.type.type,
pycparser.c_ast.IdentifierType) and
+
decl.type.type.names[-1].startswith('__dotdotdot')):
realtype = self._get_unknown_type(decl)
elif (isinstance(decl.type, pycparser.c_ast.PtrDecl) and
isinstance(decl.type.type, pycparser.c_ast.TypeDecl)
and
isinstance(decl.type.type.type,
pycparser.c_ast.IdentifierType) and
- decl.type.type.type.names == ['__dotdotdot__']):
- realtype = model.unknown_ptr_type(decl.name)
+
decl.type.type.type.names[-1].startswith('__dotdotdot')):
+ realtype = self._get_unknown_ptr_type(decl)
else:
realtype, quals = self._get_type_and_quals(
decl.type, name=decl.name, partial_length_ok=True)
@@ -832,24 +842,25 @@
def _get_unknown_type(self, decl):
typenames = decl.type.type.names
- assert typenames[-1] == '__dotdotdot__'
- if len(typenames) == 1:
+ if typenames == ['__dotdotdot__']:
return model.unknown_type(decl.name)
- if (typenames[:-1] == ['float'] or
- typenames[:-1] == ['double']):
- # not for 'long double' so far
- result = model.UnknownFloatType(decl.name)
- else:
- for t in typenames[:-1]:
- if t not in ['int', 'short', 'long', 'signed',
- 'unsigned', 'char']:
- raise FFIError(':%d: bad usage of "..."' %
- decl.coord.line)
- result = model.UnknownIntegerType(decl.name)
+ if typenames == ['__dotdotdotint__']:
+ if self._uses_new_feature is None:
+ self._uses_new_feature = "'typedef int... %s'" % decl.name
+ return model.UnknownIntegerType(decl.name)
- if self._uses_new_feature is None:
- self._uses_new_feature = "'typedef %s... %s'" % (
- ' '.join(typenames[:-1]), decl.name)
+ if typenames == ['__dotdotdotfloat__']:
+ # note: not for 'long double' so far
+ if self._uses_new_feature is None:
+ self._uses_new_feature = "'typedef float... %s'" % decl.name
+ return model.UnknownFloatType(decl.name)
- return result
+ raise FFIError(':%d: unsupported usage of "..." in typedef'
+ % decl.coord.line)
+
+ def _get_unknown_ptr_type(self, decl):
+ if decl.type.type.type.names == ['__dotdotdot__']:
+ return model.unknown_ptr_type(decl.name)
+ raise FFIError(':%d: unsupported usage of "..." in typedef'
+ % decl.coord.line)
diff --git a/pypy/module/cpyext/test/test_typeobject.py
b/pypy/module/cpyext/test/test_typeobject.py
--- a/pypy/module/cpyext/test/test_typeobject.py
+++ b/pypy/module/cpyext/test/test_typeobject.py
@@ -1141,7 +1141,7 @@
Base1->tp_basicsize = sizeof(PyHeapTypeObject);
Base2->tp_basicsize = sizeof(PyHeapTypeObject);
Base12->tp_basicsize = sizeof(PyHeapTypeObject);
- #ifndef PYPY_VERSION /* PyHeapTypeObject has no ht_qualname on
PyPy */
+ #ifndef PYPY_VERSION /* PyHeapTypeObject has no ht_qualname
nor ht_name on PyPy */
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 3
{
PyObject * dummyname = PyBytes_FromString("dummy name");
@@ -1149,8 +1149,15 @@
((PyHeapTypeObject*)Base2)->ht_qualname = dummyname;
((PyHeapTypeObject*)Base12)->ht_qualname = dummyname;
}
- #endif
- #endif
+ #elif PY_MAJOR_VERSION == 2
+ {
+ PyObject * dummyname = PyBytes_FromString("dummy name");
+ ((PyHeapTypeObject*)Base1)->ht_name = dummyname;
+ ((PyHeapTypeObject*)Base2)->ht_name = dummyname;
+ ((PyHeapTypeObject*)Base12)->ht_name = dummyname;
+ }
+ #endif
+ #endif
Base1->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
Py_TPFLAGS_HEAPTYPE;
Base2->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
Py_TPFLAGS_HEAPTYPE;
Base12->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE;
diff --git a/pypy/module/pypyjit/test_pypy_c/test_ffi.py
b/pypy/module/pypyjit/test_pypy_c/test_ffi.py
--- a/pypy/module/pypyjit/test_pypy_c/test_ffi.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_ffi.py
@@ -424,7 +424,7 @@
# NB. we get threads because '_hashlib' uses ffi callback/def_extern
--THREAD-TICK--
i123 = arraylen_gc(p67, descr=<ArrayP .>)
- i119 = call_i(ConstClass(_ll_1_raw_malloc_varsize_zero__Signed), 6,
descr=<Calli . i EF=5 OS=110>)
+ i119 =
call_i(ConstClass(_ll_1_raw_malloc_varsize_zero_mpressure__Signed), 6,
descr=<Calli . i EF=5 OS=110>)
check_memory_error(i119)
raw_store(i119, 0, i160, descr=<ArrayS 2>)
raw_store(i119, 2, i160, descr=<ArrayS 2>)
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_verify.py
b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_verify.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_verify.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_verify.py
@@ -2247,10 +2247,10 @@
assert str(e.value) == ("feature not supported with ffi.verify(), but only
"
"with ffi.set_source(): 'typedef int... t1'")
ffi = FFI()
- ffi.cdef("typedef unsigned long... t1;")
+ ffi.cdef("typedef double ... t1;")
e = py.test.raises(VerificationError, ffi.verify, "")
assert str(e.value) == ("feature not supported with ffi.verify(), but only
"
- "with ffi.set_source(): 'typedef unsigned long...
t1'")
+ "with ffi.set_source(): 'typedef float... t1'")
def test_const_fields():
ffi = FFI()
diff --git a/rpython/jit/codewriter/call.py b/rpython/jit/codewriter/call.py
--- a/rpython/jit/codewriter/call.py
+++ b/rpython/jit/codewriter/call.py
@@ -202,12 +202,12 @@
ARGS = FUNC.ARGS
if NON_VOID_ARGS != [T for T in ARGS if T is not lltype.Void]:
raise Exception(
- "in operation %r: caling a function with signature %r, "
+ "in operation %r: calling a function with signature %r, "
"but passing actual arguments (ignoring voids) of types %r"
% (op, FUNC, NON_VOID_ARGS))
if RESULT != FUNC.RESULT:
raise Exception(
- "in operation %r: caling a function with signature %r, "
+ "in operation %r: calling a function with signature %r, "
"but the actual return type is %r" % (op, FUNC, RESULT))
# ok
# get the 'elidable' and 'loopinvariant' flags from the function object
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit