Author: Matti Picus <[email protected]>
Branch: py3.5
Changeset: r91636:c378444b2cf5
Date: 2017-06-22 23:14 +0300
http://bitbucket.org/pypy/pypy/changeset/c378444b2cf5/
Log: hg merge default
diff --git a/lib_pypy/cffi/_cffi_errors.h b/lib_pypy/cffi/_cffi_errors.h
--- a/lib_pypy/cffi/_cffi_errors.h
+++ b/lib_pypy/cffi/_cffi_errors.h
@@ -36,7 +36,11 @@
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);
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
@@ -765,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:
@@ -775,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/pypy/doc/project-ideas.rst b/pypy/doc/project-ideas.rst
--- a/pypy/doc/project-ideas.rst
+++ b/pypy/doc/project-ideas.rst
@@ -238,18 +238,17 @@
using more pypy-friendly technologies, e.g. cffi. Here is a partial list of
good work that needs to be finished:
-**matplotlib** https://github.com/mattip/matplotlib
+**matplotlib** https://github.com/matplotlib/matplotlib
- Status: the repo is an older version of matplotlib adapted to pypy and
cpyext
+ TODO: the tkagg backend does not work, which makes tests fail on downstream
+ projects like Pandas, SciPy. It uses id(obj) as a c-pointer to obj in
+ tkagg.py, which requires refactoring
- TODO: A suggested first step would be to merge the differences into
- matplotlib/HEAD. The major problem is the use of a generic view into a
- numpy ndarray. The int* fields would need to be converted into
int[MAX_DIMS]
- c-arrays and filled in.
+**wxPython** https://bitbucket.org/amauryfa/wxpython-cffi
-**wxPython** https://bitbucket.org/waedt/wxpython_cffi
+ Status: A project by a PyPy developer to adapt the Phoenix sip build
system to cffi
- Status: A GSOC 2013 project to adapt the Phoenix sip build system to cffi
+ The project is a continuation of a 2013 GSOC
https://bitbucket.org/waedt/wxpython_cffi
TODO: Merge the latest version of the wrappers and finish the sip
conversion
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -17,3 +17,7 @@
.. branch: vmprof-0.4.8
Improve and fix issues with vmprof
+
+.. branch: issue-2592
+
+CPyext PyListObject.pop must return the value
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py
b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -50,6 +50,10 @@
path = None
else:
path = ctypes.util.find_library(name)
+ if path is None and name == 'c':
+ assert sys.platform == 'win32'
+ assert sys.version_info >= (3,)
+ py.test.skip("dlopen(None) cannot work on Windows with Python 3")
return load_library(path, flags)
def test_load_library():
diff --git a/pypy/module/cpyext/dictobject.py b/pypy/module/cpyext/dictobject.py
--- a/pypy/module/cpyext/dictobject.py
+++ b/pypy/module/cpyext/dictobject.py
@@ -286,6 +286,7 @@
pvalue[0] = as_pyobj(space, w_value)
return 1
+ _frozendict_cache[space].flag_map_or_seq = 'M'
@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
def _PyDict_HasOnlyStringKeys(space, w_dict):
keys_w = space.unpackiterable(w_dict)
diff --git a/pypy/module/cpyext/sequence.py b/pypy/module/cpyext/sequence.py
--- a/pypy/module/cpyext/sequence.py
+++ b/pypy/module/cpyext/sequence.py
@@ -346,11 +346,11 @@
def pop(self, w_list, index):
w_list.switch_to_object_strategy()
- w_list.strategy.pop(w_list, index)
+ return w_list.strategy.pop(w_list, index)
def pop_end(self, w_list):
w_list.switch_to_object_strategy()
- w_list.strategy.pop_end(w_list)
+ return w_list.strategy.pop_end(w_list)
def insert(self, w_list, index, w_item):
w_list.switch_to_object_strategy()
diff --git a/pypy/module/cpyext/test/test_iterator.py
b/pypy/module/cpyext/test/test_iterator.py
--- a/pypy/module/cpyext/test/test_iterator.py
+++ b/pypy/module/cpyext/test/test_iterator.py
@@ -33,6 +33,11 @@
return obj;
'''
),
+ ("get_dictproxy", "METH_O",
+ '''
+ return PyDictProxy_New(args);
+ '''
+ ),
("check", "METH_O",
'''
return PyLong_FromLong(
@@ -70,6 +75,10 @@
assert str(e.value).endswith("object is not iterable")
#
assert module.check(obj) == 2
+ # make sure dictionaries return false for PySequence_Check
+ assert module.check({'a': 1}) == 2
+ obj = module.get_dictproxy({'a': 10})
+ assert module.check(obj) == 2
def test_iterable_nonmapping_object(self):
module = self.import_extension('foo', [
diff --git a/pypy/module/cpyext/test/test_listobject.py
b/pypy/module/cpyext/test/test_listobject.py
--- a/pypy/module/cpyext/test/test_listobject.py
+++ b/pypy/module/cpyext/test/test_listobject.py
@@ -150,6 +150,13 @@
# tp_as_sequence should be filled, but tp_as_number should be NULL
assert module.test_tp_as_() == 3
+ l = module.newlist()
+ p = l.pop()
+ assert p == 1000
+ p = l.pop(0)
+ assert p == 3
+ assert l == [-5]
+
def test_list_macros(self):
"""The PyList_* macros cast, and calls expecting that build."""
module = self.import_extension('foo', [
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/backend_tests.py
b/pypy/module/test_lib_pypy/cffi_tests/cffi0/backend_tests.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi0/backend_tests.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi0/backend_tests.py
@@ -11,6 +11,10 @@
SIZE_OF_PTR = ctypes.sizeof(ctypes.c_void_p)
SIZE_OF_WCHAR = ctypes.sizeof(ctypes.c_wchar)
+def needs_dlopen_none():
+ if sys.platform == 'win32' and sys.version_info >= (3,):
+ py.test.skip("dlopen(None) cannot work on Windows for Python 3")
+
class BackendTests:
@@ -355,7 +359,6 @@
#
p = ffi.new("wchar_t[]", u+'\U00023456')
if SIZE_OF_WCHAR == 2:
- assert sys.maxunicode == 0xffff
assert len(p) == 3
assert p[0] == u+'\ud84d'
assert p[1] == u+'\udc56'
@@ -938,6 +941,7 @@
def test_enum_partial(self):
ffi = FFI(backend=self.Backend())
ffi.cdef(r"enum foo {A, ...}; enum bar { B, C };")
+ needs_dlopen_none()
lib = ffi.dlopen(None)
assert lib.B == 0
py.test.raises(VerificationMissing, getattr, lib, "A")
@@ -1845,6 +1849,7 @@
#define DOT_UL 1000UL
enum foo {AA, BB=DOT, CC};
""")
+ needs_dlopen_none()
lib = ffi.dlopen(None)
assert ffi.string(ffi.cast("enum foo", 100)) == "BB"
assert lib.DOT_0 == 0
@@ -1874,6 +1879,7 @@
ffi = FFI()
ffi.include(ffi1)
ffi.cdef("enum { EE2, EE3 };")
+ needs_dlopen_none()
lib = ffi.dlopen(None)
assert lib.EE1 == 0
assert lib.EE2 == 0
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_function.py
b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_function.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_function.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_function.py
@@ -6,6 +6,7 @@
from cffi.backend_ctypes import CTypesBackend
from pypy.module.test_lib_pypy.cffi_tests.udir import udir
from pypy.module.test_lib_pypy.cffi_tests.support import FdWriteCapture
+from .backend_tests import needs_dlopen_none
try:
from StringIO import StringIO
@@ -112,6 +113,7 @@
int fputs(const char *, void *);
void *stderr;
""")
+ needs_dlopen_none()
ffi.C = ffi.dlopen(None)
ffi.C.fputs # fetch before capturing, for easier debugging
with FdWriteCapture() as fd:
@@ -128,6 +130,7 @@
int fputs(char *, void *);
void *stderr;
""")
+ needs_dlopen_none()
ffi.C = ffi.dlopen(None)
ffi.C.fputs # fetch before capturing, for easier debugging
with FdWriteCapture() as fd:
@@ -144,6 +147,7 @@
int fprintf(void *, const char *format, ...);
void *stderr;
""")
+ needs_dlopen_none()
ffi.C = ffi.dlopen(None)
with FdWriteCapture() as fd:
ffi.C.fprintf(ffi.C.stderr, b"hello with no arguments\n")
@@ -170,6 +174,7 @@
ffi.cdef("""
int printf(const char *format, ...);
""")
+ needs_dlopen_none()
ffi.C = ffi.dlopen(None)
e = py.test.raises(TypeError, ffi.C.printf, b"hello %d\n", 42)
assert str(e.value) == ("argument 2 passed in the variadic part "
@@ -180,6 +185,7 @@
ffi.cdef("""
int puts(const char *);
""")
+ needs_dlopen_none()
ffi.C = ffi.dlopen(None)
fptr = ffi.C.puts
assert ffi.typeof(fptr) == ffi.typeof("int(*)(const char*)")
@@ -203,6 +209,7 @@
int fputs(const char *, void *);
void *stderr;
""")
+ needs_dlopen_none()
ffi.C = ffi.dlopen(None)
fptr = ffi.cast("int(*)(const char *txt, void *)", ffi.C.fputs)
assert fptr == ffi.C.fputs
@@ -236,6 +243,7 @@
ffi.cdef("""
int strlen(char[]);
""")
+ needs_dlopen_none()
ffi.C = ffi.dlopen(None)
p = ffi.new("char[]", b"hello")
res = ffi.C.strlen(p)
@@ -248,6 +256,7 @@
ffi.cdef("""
void *stdout;
""")
+ needs_dlopen_none()
C = ffi.dlopen(None)
pout = C.stdout
C.stdout = ffi.NULL
@@ -260,6 +269,7 @@
ffi.cdef("""
char *strchr(const char *s, int c);
""")
+ needs_dlopen_none()
ffi.C = ffi.dlopen(None)
p = ffi.new("char[]", b"hello world!")
q = ffi.C.strchr(p, ord('w'))
@@ -276,6 +286,7 @@
struct in_addr { unsigned int s_addr; };
char *inet_ntoa(struct in_addr in);
""")
+ needs_dlopen_none()
ffi.C = ffi.dlopen(None)
ina = ffi.new("struct in_addr *", [0x04040404])
a = ffi.C.inet_ntoa(ina[0])
@@ -297,6 +308,7 @@
filename = str(udir.join('fputs_custom_FILE'))
ffi = FFI(backend=self.Backend())
ffi.cdef("int fputs(const char *, FILE *);")
+ needs_dlopen_none()
C = ffi.dlopen(None)
with open(filename, 'wb') as f:
f.write(b'[')
@@ -312,6 +324,7 @@
ffi = FFI(backend=self.Backend())
ffi.cdef("""enum foo_e { AA, BB, CC=5, DD };
typedef enum { EE=-5, FF } some_enum_t;""")
+ needs_dlopen_none()
lib = ffi.dlopen(None)
assert lib.AA == 0
assert lib.BB == 1
@@ -323,6 +336,7 @@
def test_void_star_accepts_string(self):
ffi = FFI(backend=self.Backend())
ffi.cdef("""int strlen(const void *);""")
+ needs_dlopen_none()
lib = ffi.dlopen(None)
res = lib.strlen(b"hello")
assert res == 5
@@ -332,6 +346,7 @@
py.test.skip("not supported by the ctypes backend")
ffi = FFI(backend=self.Backend())
ffi.cdef("""int strlen(signed char *);""")
+ needs_dlopen_none()
lib = ffi.dlopen(None)
res = lib.strlen(b"hello")
assert res == 5
@@ -341,6 +356,7 @@
py.test.skip("not supported by the ctypes backend")
ffi = FFI(backend=self.Backend())
ffi.cdef("""int strlen(unsigned char *);""")
+ needs_dlopen_none()
lib = ffi.dlopen(None)
res = lib.strlen(b"hello")
assert res == 5
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py
b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py
@@ -1,6 +1,8 @@
# Generated by pypy/tool/import_cffi.py
import py, sys, re
from cffi import FFI, FFIError, CDefError, VerificationError
+from .backend_tests import needs_dlopen_none
+
class FakeBackend(object):
@@ -91,6 +93,7 @@
def test_pipe():
ffi = FFI(backend=FakeBackend())
ffi.cdef("int pipe(int pipefd[2]);")
+ needs_dlopen_none()
C = ffi.dlopen(None)
func = C.pipe
assert func.name == 'pipe'
@@ -99,6 +102,7 @@
def test_vararg():
ffi = FFI(backend=FakeBackend())
ffi.cdef("short foo(int, ...);")
+ needs_dlopen_none()
C = ffi.dlopen(None)
func = C.foo
assert func.name == 'foo'
@@ -109,6 +113,7 @@
ffi.cdef("""
int foo(void);
""")
+ needs_dlopen_none()
C = ffi.dlopen(None)
assert C.foo.BType == '<func (), <int>, False>'
@@ -119,6 +124,7 @@
typedef UInt UIntReally;
UInt foo(void);
""")
+ needs_dlopen_none()
C = ffi.dlopen(None)
assert str(ffi.typeof("UIntReally")) == '<unsigned int>'
assert C.foo.BType == '<func (), <unsigned int>, False>'
@@ -129,6 +135,7 @@
typedef struct { int a, b; } foo_t, *foo_p;
int foo(foo_p[]);
""")
+ needs_dlopen_none()
C = ffi.dlopen(None)
assert str(ffi.typeof("foo_t")) == '<int>a, <int>b'
assert str(ffi.typeof("foo_p")) == '<pointer to <int>a, <int>b>'
@@ -218,6 +225,7 @@
def test_override():
ffi = FFI(backend=FakeBackend())
+ needs_dlopen_none()
C = ffi.dlopen(None)
ffi.cdef("int foo(void);")
py.test.raises(FFIError, ffi.cdef, "long foo(void);")
@@ -404,6 +412,7 @@
ffi.cdef("""
enum Enum { POS = +1, TWO = 2, NIL = 0, NEG = -1, OP = (POS+TWO)-1};
""")
+ needs_dlopen_none()
C = ffi.dlopen(None)
assert C.POS == 1
assert C.TWO == 2
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_new_ffi_1.py
b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_new_ffi_1.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_new_ffi_1.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_new_ffi_1.py
@@ -419,7 +419,6 @@
#
p = ffi.new("wchar_t[]", u+'\U00023456')
if SIZE_OF_WCHAR == 2:
- assert sys.maxunicode == 0xffff
assert len(p) == 3
assert p[0] == u+'\ud84d'
assert p[1] == u+'\udc56'
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_re_python.py
b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_re_python.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_re_python.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_re_python.py
@@ -95,6 +95,8 @@
if sys.platform == 'win32':
import ctypes.util
name = ctypes.util.find_msvcrt()
+ if name is None:
+ py.test.skip("dlopen(None) cannot work on Windows with Python 3")
lib = ffi.dlopen(name)
assert lib.strlen(b"hello") == 5
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py
b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py
@@ -2260,6 +2260,9 @@
assert ffi.typeof("int16_t") is ffi.typeof("char16_t") is
ffi.typeof("long")
def test_char16_char32_type(no_cpp=False):
+ if no_cpp is False and sys.platform == "win32":
+ py.test.skip("aaaaaaa why do modern MSVC compilers still define "
+ "a very old __cplusplus value")
ffi = FFI()
ffi.cdef("""
char16_t foo_2bytes(char16_t);
@@ -2270,7 +2273,7 @@
typedef uint_least16_t char16_t;
typedef uint_least32_t char32_t;
#endif
-
+
char16_t foo_2bytes(char16_t a) { return (char16_t)(a + 42); }
char32_t foo_4bytes(char32_t a) { return (char32_t)(a + 42); }
""", no_cpp=no_cpp)
diff --git a/pypy/module/test_lib_pypy/cffi_tests/embedding/initerror.py
b/pypy/module/test_lib_pypy/cffi_tests/embedding/initerror.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/test_lib_pypy/cffi_tests/embedding/initerror.py
@@ -0,0 +1,19 @@
+# Generated by pypy/tool/import_cffi.py
+import cffi
+
+ffi = cffi.FFI()
+
+ffi.embedding_api("""
+ int add1(int, int);
+""")
+
+ffi.embedding_init_code(r"""
+ raise KeyError
+""")
+
+ffi.set_source("_initerror_cffi", """
+""")
+
+fn = ffi.compile(verbose=True)
+print('FILENAME: %s' % (fn,))
+
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit