Author: Matti Picus <[email protected]>
Branch: release-pypy3.6-v7.x
Changeset: r98160:1249df1fb9cf
Date: 2019-11-26 08:51 -0800
http://bitbucket.org/pypy/pypy/changeset/1249df1fb9cf/
Log: merge py3.6 into release-pypy3
diff too long, truncating to 2000 out of 13495 lines
diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -50,4 +50,10 @@
de061d87e39c7df4e436974096d7982c676a859d release-pypy3.6-v7.1.0
784b254d669919c872a505b807db8462b6140973 release-pypy3.6-v7.1.1
8cdda8b8cdb8ff29d9e620cccd6c5edd2f2a23ec release-pypy2.7-v7.1.1
-
+85dae4fd5c234b482feff834c73e089872194541 release-pypy2.7-v7.2.0rc0
+7ffb92269488f37c707ce66076f50ffd8613f8e2 release-pypy3.6-v7.2.0rc0
+4d6761df14ffd6f38450f183ac1fad32c946c21b release-pypy3.6-v7.2.0rc1
+5da45ced70e515f94686be0df47c59abd1348ebc release-pypy3.6-v7.2.0rc2
+4a68d8d3d2fc1faec2e83bcb4d28559099092574 release-pypy2.7-v7.2.0rc2
+4a68d8d3d2fc1faec2e83bcb4d28559099092574 release-pypy2.7-v7.2.0
+5da45ced70e515f94686be0df47c59abd1348ebc release-pypy3.6-v7.2.0
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -3,10 +3,11 @@
License
=======
-Except when otherwise stated (look for LICENSE files in directories or
-information at the beginning of each file) all software and documentation in
-the 'rpython', 'pypy', 'ctype_configure', 'dotviewer', 'demo', 'lib_pypy',
-'py', and '_pytest' directories is licensed as follows:
+Except when otherwise stated (look for LICENSE files in directories
+or information at the beginning of each file) all software and
+documentation in the 'rpython', 'pypy', 'ctype_configure', 'dotviewer',
+'demo', 'extra_tests', 'include', 'lib_pypy', 'py', and '_pytest'
+directories is licensed as follows:
The MIT License
@@ -98,16 +99,16 @@
Spenser Bauman
Michal Bendowski
Jan de Mooij
+ Stefano Rivera
Tyler Wade
+ Stefan Beyer
Vincent Legoll
Michael Foord
Stephan Diehl
- Stefano Rivera
Jean-Paul Calderone
Stefan Schwarzer
Tomek Meka
Valentino Volonghi
- Stefan Beyer
Patrick Maupin
Devin Jeanpierre
Bob Ippolito
@@ -136,9 +137,10 @@
Jean-Philippe St. Pierre
Guido van Rossum
Pavel Vinogradov
+ Stian Andreassen
+ Julian Berman
William Leslie
Paweł Piotr Przeradowski
- Stian Andreassen
marky1991
Ilya Osadchiy
Tobias Oberstein
@@ -149,7 +151,7 @@
tav
Georg Brandl
Joannah Nanjekye
- Julian Berman
+ Yannick Jadoul
Bert Freudenberg
Wanja Saatkamp
Mike Blume
@@ -274,6 +276,7 @@
Lutz Paelike
Ian Foote
Philipp Rustemeuer
+ Bernd Schoeller
Logan Chien
Catalin Gabriel Manciu
Jacob Oscarson
@@ -301,7 +304,6 @@
Laurens Van Houtven
Bobby Impollonia
Roberto De Ioris
- Yannick Jadoul
Jeong YunWon
Christopher Armstrong
Aaron Tubbs
@@ -356,6 +358,7 @@
Daniil Yarancev
Min RK
OlivierBlanvillain
+ [email protected]
[email protected]
Jonas Pfannschmidt
Zearin
@@ -397,6 +400,7 @@
Jesdi
Konrad Delong
Dinu Gherman
+ Sam Edwards
pizi
Tomáš Pružina
James Robert
diff --git a/README.rst b/README.rst
--- a/README.rst
+++ b/README.rst
@@ -9,15 +9,15 @@
The home page for the interpreter is:
- http://pypy.org/
+ https://pypy.org/
If you want to help developing PyPy, this documentation might help you:
- http://doc.pypy.org/
+ https://doc.pypy.org/
More documentation about the RPython framework can be found here:
- http://rpython.readthedocs.io/
+ https://rpython.readthedocs.io/
The source for the documentation is in the pypy/doc directory.
@@ -25,7 +25,7 @@
Using PyPy instead of CPython
-----------------------------
-Please read the information at http://pypy.org/ to find the correct way to
+Please read the information at https://pypy.org/ to find the correct way to
download and use PyPy as an alternative to CPython.
@@ -36,7 +36,7 @@
interpreter. It is time-consuming and requires significant computing resources.
More information can be found here:
- http://doc.pypy.org/en/latest/build.html
+ https://doc.pypy.org/en/latest/build.html
Enjoy and send us feedback!
diff --git a/extra_tests/cffi_tests/cffi0/test_function.py
b/extra_tests/cffi_tests/cffi0/test_function.py
--- a/extra_tests/cffi_tests/cffi0/test_function.py
+++ b/extra_tests/cffi_tests/cffi0/test_function.py
@@ -114,7 +114,7 @@
ffi = FFI(backend=self.Backend())
ffi.cdef("""
int fputs(const char *, void *);
- void *stderr;
+ extern void *stderr;
""")
needs_dlopen_none()
ffi.C = ffi.dlopen(None)
@@ -131,7 +131,7 @@
ffi = FFI(backend=self.Backend())
ffi.cdef("""
int fputs(char *, void *);
- void *stderr;
+ extern void *stderr;
""")
needs_dlopen_none()
ffi.C = ffi.dlopen(None)
@@ -148,7 +148,7 @@
ffi = FFI(backend=self.Backend())
ffi.cdef("""
int fprintf(void *, const char *format, ...);
- void *stderr;
+ extern void *stderr;
""")
needs_dlopen_none()
ffi.C = ffi.dlopen(None)
@@ -210,7 +210,7 @@
py.test.skip("probably no symbol 'stderr' in the lib")
ffi.cdef("""
int fputs(const char *, void *);
- void *stderr;
+ extern void *stderr;
""")
needs_dlopen_none()
ffi.C = ffi.dlopen(None)
@@ -257,7 +257,7 @@
py.test.skip("probably no symbol 'stdout' in the lib")
ffi = FFI(backend=self.Backend())
ffi.cdef("""
- void *stdout;
+ extern void *stdout;
""")
needs_dlopen_none()
C = ffi.dlopen(None)
@@ -497,7 +497,7 @@
ffi.cdef("""
typedef enum { MYE1, MYE2 } myenum_t;
double myfunc(double);
- double myvar;
+ extern double myvar;
const double myconst;
#define MYFOO 42
""")
@@ -508,7 +508,7 @@
if self.Backend is CTypesBackend:
py.test.skip("not with the ctypes backend")
ffi = FFI(backend=self.Backend())
- ffi.cdef("int foobar(void); int foobaz;")
+ ffi.cdef("int foobar(void); extern int foobaz;")
lib = ffi.dlopen(lib_m)
ffi.dlclose(lib)
e = py.test.raises(ValueError, getattr, lib, 'foobar')
diff --git a/extra_tests/cffi_tests/cffi0/test_ownlib.py
b/extra_tests/cffi_tests/cffi0/test_ownlib.py
--- a/extra_tests/cffi_tests/cffi0/test_ownlib.py
+++ b/extra_tests/cffi_tests/cffi0/test_ownlib.py
@@ -202,7 +202,7 @@
py.test.skip("fix the auto-generation of the tiny test lib")
ffi = FFI(backend=self.Backend())
ffi.cdef("""
- int my_array[7];
+ extern int my_array[7];
""")
ownlib = ffi.dlopen(self.module)
for i in range(7):
@@ -224,7 +224,7 @@
py.test.skip("not supported by the ctypes backend")
ffi = FFI(backend=self.Backend())
ffi.cdef("""
- int my_array[];
+ extern int my_array[];
""")
ownlib = ffi.dlopen(self.module)
for i in range(7):
@@ -292,7 +292,7 @@
long bottom;
} RECT;
- long left, top, right, bottom;
+ extern long left, top, right, bottom;
RECT ReturnRect(int i, RECT ar, RECT* br, POINT cp, RECT dr,
RECT *er, POINT fp, RECT gr);
@@ -322,7 +322,7 @@
if self.Backend is CTypesBackend:
py.test.skip("not implemented with the ctypes backend")
ffi = FFI(backend=self.Backend())
- ffi.cdef("long left; int test_getting_errno(void);")
+ ffi.cdef("extern long left; int test_getting_errno(void);")
lib = ffi.dlopen(self.module)
lib.left = 123456
p = ffi.addressof(lib, "left")
diff --git a/extra_tests/cffi_tests/cffi0/test_parsing.py
b/extra_tests/cffi_tests/cffi0/test_parsing.py
--- a/extra_tests/cffi_tests/cffi0/test_parsing.py
+++ b/extra_tests/cffi_tests/cffi0/test_parsing.py
@@ -325,6 +325,7 @@
assert value == sys.maxsize * 2 - 40
def test__is_constant_globalvar():
+ import warnings
for input, expected_output in [
("int a;", False),
("const int a;", True),
@@ -342,10 +343,13 @@
("const int a[5][6];", False),
]:
ffi = FFI()
- ffi.cdef(input)
+ with warnings.catch_warnings(record=True) as log:
+ warnings.simplefilter("always")
+ ffi.cdef(input)
declarations = ffi._parser._declarations
assert ('constant a' in declarations) == expected_output
assert ('variable a' in declarations) == (not expected_output)
+ assert len(log) == (1 - expected_output)
def test_restrict():
from cffi import model
@@ -355,7 +359,7 @@
("int *a;", False),
]:
ffi = FFI()
- ffi.cdef(input)
+ ffi.cdef("extern " + input)
tp, quals = ffi._parser._declarations['variable a']
assert bool(quals & model.Q_RESTRICT) == expected_output
diff --git a/extra_tests/cffi_tests/cffi0/test_verify.py
b/extra_tests/cffi_tests/cffi0/test_verify.py
--- a/extra_tests/cffi_tests/cffi0/test_verify.py
+++ b/extra_tests/cffi_tests/cffi0/test_verify.py
@@ -4,6 +4,7 @@
import sys, os, math, weakref
from cffi import FFI, VerificationError, VerificationMissing, model, FFIError
from extra_tests.cffi_tests.support import *
+from extra_tests.cffi_tests.support import extra_compile_args
lib_m = ['m']
@@ -14,17 +15,6 @@
lib_m = ['msvcrt']
pass # no obvious -Werror equivalent on MSVC
else:
- if (sys.platform == 'darwin' and
- [int(x) for x in os.uname()[2].split('.')] >= [11, 0, 0]):
- # assume a standard clang or gcc
- extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion']
- # special things for clang
- extra_compile_args.append('-Qunused-arguments')
- else:
- # assume a standard gcc
- extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion',
- '-Wno-unused-parameter']
-
class FFI(FFI):
def verify(self, *args, **kwds):
return super(FFI, self).verify(
@@ -287,7 +277,7 @@
def test_var_signed_integer_types():
ffi = FFI()
lst = all_signed_integer_types(ffi)
- csource = "\n".join(["%s somevar_%s;" % (tp, tp.replace(' ', '_'))
+ csource = "\n".join(["static %s somevar_%s;" % (tp, tp.replace(' ', '_'))
for tp in lst])
ffi.cdef(csource)
lib = ffi.verify(csource)
@@ -306,7 +296,7 @@
def test_var_unsigned_integer_types():
ffi = FFI()
lst = all_unsigned_integer_types(ffi)
- csource = "\n".join(["%s somevar_%s;" % (tp, tp.replace(' ', '_'))
+ csource = "\n".join(["static %s somevar_%s;" % (tp, tp.replace(' ', '_'))
for tp in lst])
ffi.cdef(csource)
lib = ffi.verify(csource)
@@ -818,8 +808,8 @@
def test_access_variable():
ffi = FFI()
- ffi.cdef("int foo(void);\n"
- "int somenumber;")
+ ffi.cdef("static int foo(void);\n"
+ "static int somenumber;")
lib = ffi.verify("""
static int somenumber = 2;
static int foo(void) {
@@ -836,7 +826,7 @@
def test_access_address_of_variable():
# access the address of 'somenumber': need a trick
ffi = FFI()
- ffi.cdef("int somenumber; static int *const somenumberptr;")
+ ffi.cdef("static int somenumber; static int *const somenumberptr;")
lib = ffi.verify("""
static int somenumber = 2;
#define somenumberptr (&somenumber)
@@ -849,7 +839,7 @@
def test_access_array_variable(length=5):
ffi = FFI()
ffi.cdef("int foo(int);\n"
- "int somenumber[%s];" % (length,))
+ "static int somenumber[%s];" % (length,))
lib = ffi.verify("""
static int somenumber[] = {2, 2, 3, 4, 5};
static int foo(int i) {
@@ -881,7 +871,7 @@
ffi = FFI()
ffi.cdef("struct foo { int x; ...; };\n"
"int foo(int);\n"
- "struct foo stuff;")
+ "static struct foo stuff;")
lib = ffi.verify("""
struct foo { int x, y, z; };
static struct foo stuff = {2, 5, 8};
@@ -905,9 +895,9 @@
def test_access_callback():
ffi = FFI()
- ffi.cdef("int (*cb)(int);\n"
- "int foo(int);\n"
- "void reset_cb(void);")
+ ffi.cdef("static int (*cb)(int);\n"
+ "static int foo(int);\n"
+ "static void reset_cb(void);")
lib = ffi.verify("""
static int g(int x) { return x * 7; }
static int (*cb)(int);
@@ -923,9 +913,9 @@
def test_access_callback_function_typedef():
ffi = FFI()
ffi.cdef("typedef int mycallback_t(int);\n"
- "mycallback_t *cb;\n"
- "int foo(int);\n"
- "void reset_cb(void);")
+ "static mycallback_t *cb;\n"
+ "static int foo(int);\n"
+ "static void reset_cb(void);")
lib = ffi.verify("""
static int g(int x) { return x * 7; }
static int (*cb)(int);
@@ -1075,7 +1065,7 @@
def test_autofilled_struct_as_argument_dynamic():
ffi = FFI()
ffi.cdef("struct foo_s { long a; ...; };\n"
- "int (*foo)(struct foo_s);")
+ "static int (*foo)(struct foo_s);")
lib = ffi.verify("""
struct foo_s {
double b;
@@ -1084,7 +1074,7 @@
int foo1(struct foo_s s) {
return (int)s.a - (int)s.b;
}
- int (*foo)(struct foo_s s) = &foo1;
+ static int (*foo)(struct foo_s s) = &foo1;
""")
e = py.test.raises(NotImplementedError, lib.foo, "?")
msg = ("ctype 'struct foo_s' not supported as argument. It is a struct "
@@ -1454,7 +1444,7 @@
py.test.skip("_Bool not in MSVC")
ffi = FFI()
ffi.cdef("struct foo_s { _Bool x; };"
- "_Bool foo(_Bool); _Bool (*foop)(_Bool);")
+ "_Bool foo(_Bool); static _Bool (*foop)(_Bool);")
lib = ffi.verify("""
struct foo_s { _Bool x; };
int foo(int arg) {
@@ -1463,7 +1453,7 @@
_Bool _foofunc(_Bool x) {
return !x;
}
- _Bool (*foop)(_Bool) = _foofunc;
+ static _Bool (*foop)(_Bool) = _foofunc;
""")
p = ffi.new("struct foo_s *")
p.x = 1
@@ -1654,7 +1644,7 @@
def test_FILE_stored_explicitly():
ffi = FFI()
- ffi.cdef("int myprintf11(const char *, int); FILE *myfile;")
+ ffi.cdef("int myprintf11(const char *, int); extern FILE *myfile;")
lib = ffi.verify("""
#include <stdio.h>
FILE *myfile;
@@ -1680,19 +1670,19 @@
def test_global_array_with_missing_length():
ffi = FFI()
- ffi.cdef("int fooarray[];")
+ ffi.cdef("extern int fooarray[];")
lib = ffi.verify("int fooarray[50];")
assert repr(lib.fooarray).startswith("<cdata 'int *'")
def test_global_array_with_dotdotdot_length():
ffi = FFI()
- ffi.cdef("int fooarray[...];")
+ ffi.cdef("extern int fooarray[...];")
lib = ffi.verify("int fooarray[50];")
assert repr(lib.fooarray).startswith("<cdata 'int[50]'")
def test_bad_global_array_with_dotdotdot_length():
ffi = FFI()
- ffi.cdef("int fooarray[...];")
+ ffi.cdef("extern int fooarray[...];")
py.test.raises(VerificationError, ffi.verify, "char fooarray[23];")
def test_struct_containing_struct():
@@ -1813,7 +1803,7 @@
def test_callback_indirection():
ffi = FFI()
ffi.cdef("""
- int (*python_callback)(int how_many, int *values);
+ static int (*python_callback)(int how_many, int *values);
int (*const c_callback)(int,...); /* pass this ptr to C routines */
int some_c_function(int(*cb)(int,...));
""")
@@ -1947,24 +1937,24 @@
def test_bug_const_char_ptr_array_1():
ffi = FFI()
- ffi.cdef("""const char *a[...];""")
+ ffi.cdef("""extern const char *a[...];""")
lib = ffi.verify("""const char *a[5];""")
assert repr(ffi.typeof(lib.a)) == "<ctype 'char *[5]'>"
def test_bug_const_char_ptr_array_2():
from cffi import FFI # ignore warnings
ffi = FFI()
- ffi.cdef("""const int a[];""")
+ ffi.cdef("""extern const int a[];""")
lib = ffi.verify("""const int a[5];""")
assert repr(ffi.typeof(lib.a)) == "<ctype 'int *'>"
def _test_various_calls(force_libffi):
cdef_source = """
- int xvalue;
- long long ivalue, rvalue;
- float fvalue;
- double dvalue;
- long double Dvalue;
+ extern int xvalue;
+ extern long long ivalue, rvalue;
+ extern float fvalue;
+ extern double dvalue;
+ extern long double Dvalue;
signed char tf_bb(signed char x, signed char c);
unsigned char tf_bB(signed char x, unsigned char c);
short tf_bh(signed char x, short c);
@@ -2148,7 +2138,7 @@
# exported symbols as well. So we must not export a simple name
# like 'foo'!
ffi1 = FFI()
- ffi1.cdef("int foo_verify_dlopen_flags;")
+ ffi1.cdef("extern int foo_verify_dlopen_flags;")
lib1 = ffi1.verify("int foo_verify_dlopen_flags;",
flags=ffi1.RTLD_GLOBAL | ffi1.RTLD_LAZY)
@@ -2162,7 +2152,7 @@
def get_second_lib():
# Hack, using modulename makes the test fail
ffi2 = FFI()
- ffi2.cdef("int foo_verify_dlopen_flags;")
+ ffi2.cdef("extern int foo_verify_dlopen_flags;")
lib2 = ffi2.verify("int foo_verify_dlopen_flags;",
flags=ffi2.RTLD_GLOBAL | ffi2.RTLD_LAZY)
return lib2
diff --git a/extra_tests/cffi_tests/cffi1/test_dlopen.py
b/extra_tests/cffi_tests/cffi1/test_dlopen.py
--- a/extra_tests/cffi_tests/cffi1/test_dlopen.py
+++ b/extra_tests/cffi_tests/cffi1/test_dlopen.py
@@ -7,7 +7,7 @@
def test_simple():
ffi = FFI()
- ffi.cdef("int close(int); static const int BB = 42; int somevar;")
+ ffi.cdef("int close(int); static const int BB = 42; extern int somevar;")
target = udir.join('test_simple.py')
make_py_source(ffi, 'test_simple', str(target))
assert target.read() == r"""# auto-generated file
@@ -197,7 +197,7 @@
def test_global_var():
ffi = FFI()
- ffi.cdef("int myglob;")
+ ffi.cdef("extern int myglob;")
target = udir.join('test_global_var.py')
make_py_source(ffi, 'test_global_var', str(target))
assert target.read() == r"""# auto-generated file
diff --git a/extra_tests/cffi_tests/cffi1/test_new_ffi_1.py
b/extra_tests/cffi_tests/cffi1/test_new_ffi_1.py
--- a/extra_tests/cffi_tests/cffi1/test_new_ffi_1.py
+++ b/extra_tests/cffi_tests/cffi1/test_new_ffi_1.py
@@ -1780,7 +1780,7 @@
def test_import_from_lib(self):
ffi2 = cffi.FFI()
- ffi2.cdef("int myfunc(int); int myvar;\n#define MYFOO ...\n")
+ ffi2.cdef("int myfunc(int); extern int myvar;\n#define MYFOO ...\n")
outputfilename = recompile(ffi2, "_test_import_from_lib",
"int myfunc(int x) { return x + 1; }\n"
"int myvar = -5;\n"
diff --git a/extra_tests/cffi_tests/cffi1/test_re_python.py
b/extra_tests/cffi_tests/cffi1/test_re_python.py
--- a/extra_tests/cffi_tests/cffi1/test_re_python.py
+++ b/extra_tests/cffi_tests/cffi1/test_re_python.py
@@ -64,11 +64,11 @@
#define BIGNEG -420000000000L
int add42(int);
int add43(int, ...);
- int globalvar42;
+ extern int globalvar42;
const int globalconst42;
const char *const globalconsthello;
int no_such_function(int);
- int no_such_globalvar;
+ extern int no_such_globalvar;
struct foo_s;
typedef struct bar_s { int x; signed char a[]; } bar_t;
enum foo_e { AA, BB, CC };
@@ -76,6 +76,7 @@
struct with_union { union { int a; char b; }; };
union with_struct { struct { int a; char b; }; };
struct NVGcolor { union { float rgba[4]; struct { float r,g,b,a; }; }; };
+ typedef struct selfref { struct selfref *next; } *selfref_ptr_t;
""")
ffi.set_source('re_python_pysrc', None)
ffi.emit_python_code(str(tmpdir.join('re_python_pysrc.py')))
@@ -255,3 +256,8 @@
assert ffi.offsetof("struct NVGcolor", "g") == FLOAT
assert ffi.offsetof("struct NVGcolor", "b") == FLOAT * 2
assert ffi.offsetof("struct NVGcolor", "a") == FLOAT * 3
+
+def test_selfref():
+ # based on issue #429
+ from re_python_pysrc import ffi
+ ffi.new("selfref_ptr_t")
diff --git a/extra_tests/cffi_tests/cffi1/test_recompiler.py
b/extra_tests/cffi_tests/cffi1/test_recompiler.py
--- a/extra_tests/cffi_tests/cffi1/test_recompiler.py
+++ b/extra_tests/cffi_tests/cffi1/test_recompiler.py
@@ -35,8 +35,9 @@
source = 'extern "C" {\n%s\n}' % (source,)
elif sys.platform != 'win32':
# add '-Werror' to the existing 'extra_compile_args' flags
+ from extra_tests.cffi_tests.support import extra_compile_args
kwds['extra_compile_args'] = (kwds.get('extra_compile_args', []) +
- ['-Werror'])
+ extra_compile_args)
return _verify(ffi, module_name, source, *args, **kwds)
def test_set_source_no_slashes():
@@ -84,7 +85,7 @@
"(FUNCTION 1)(PRIMITIVE 7)(FUNCTION_END 1)(POINTER 0)")
def test_type_table_array():
- check_type_table("int a[100];",
+ check_type_table("extern int a[100];",
"(PRIMITIVE 7)(ARRAY 0)(None 100)")
def test_type_table_typedef():
@@ -159,7 +160,7 @@
def test_global_var_array():
ffi = FFI()
- ffi.cdef("int a[100];")
+ ffi.cdef("extern int a[100];")
lib = verify(ffi, 'test_global_var_array', 'int a[100] = { 9999 };')
lib.a[42] = 123456
assert lib.a[42] == 123456
@@ -183,7 +184,7 @@
def test_global_var_int():
ffi = FFI()
- ffi.cdef("int a, b, c;")
+ ffi.cdef("extern int a, b, c;")
lib = verify(ffi, 'test_global_var_int', 'int a = 999, b, c;')
assert lib.a == 999
lib.a -= 1001
@@ -284,7 +285,7 @@
def test_dir():
ffi = FFI()
- ffi.cdef("int ff(int); int aa; static const int my_constant;")
+ ffi.cdef("int ff(int); extern int aa; static const int my_constant;")
lib = verify(ffi, 'test_dir', """
#define my_constant (-45)
int aa;
@@ -406,7 +407,7 @@
def test_dotdotdot_global_array():
ffi = FFI()
- ffi.cdef("int aa[...]; int bb[...];")
+ ffi.cdef("extern int aa[...]; extern int bb[...];")
lib = verify(ffi, 'test_dotdotdot_global_array',
"int aa[41]; int bb[12];")
assert ffi.sizeof(lib.aa) == 41 * 4
@@ -561,37 +562,37 @@
def test_bad_size_of_global_1():
ffi = FFI()
- ffi.cdef("short glob;")
+ ffi.cdef("extern short glob;")
py.test.raises(VerificationError, verify, ffi,
"test_bad_size_of_global_1", "long glob;")
def test_bad_size_of_global_2():
ffi = FFI()
- ffi.cdef("int glob[10];")
+ ffi.cdef("extern int glob[10];")
py.test.raises(VerificationError, verify, ffi,
"test_bad_size_of_global_2", "int glob[9];")
def test_unspecified_size_of_global_1():
ffi = FFI()
- ffi.cdef("int glob[];")
+ ffi.cdef("extern int glob[];")
lib = verify(ffi, "test_unspecified_size_of_global_1", "int glob[10];")
assert ffi.typeof(lib.glob) == ffi.typeof("int *")
def test_unspecified_size_of_global_2():
ffi = FFI()
- ffi.cdef("int glob[][5];")
+ ffi.cdef("extern int glob[][5];")
lib = verify(ffi, "test_unspecified_size_of_global_2", "int glob[10][5];")
assert ffi.typeof(lib.glob) == ffi.typeof("int(*)[5]")
def test_unspecified_size_of_global_3():
ffi = FFI()
- ffi.cdef("int glob[][...];")
+ ffi.cdef("extern int glob[][...];")
lib = verify(ffi, "test_unspecified_size_of_global_3", "int glob[10][5];")
assert ffi.typeof(lib.glob) == ffi.typeof("int(*)[5]")
def test_unspecified_size_of_global_4():
ffi = FFI()
- ffi.cdef("int glob[...][...];")
+ ffi.cdef("extern int glob[...][...];")
lib = verify(ffi, "test_unspecified_size_of_global_4", "int glob[10][5];")
assert ffi.typeof(lib.glob) == ffi.typeof("int[10][5]")
@@ -814,7 +815,7 @@
def test_address_of_global_var():
ffi = FFI()
ffi.cdef("""
- long bottom, bottoms[2];
+ extern long bottom, bottoms[2];
long FetchRectBottom(void);
long FetchRectBottoms1(void);
#define FOOBAR 42
@@ -969,7 +970,7 @@
ffi = FFI()
ffi.cdef("""
typedef ... opaque_t;
- opaque_t globvar;
+ extern opaque_t globvar;
""")
lib = verify(ffi, 'test_variable_of_unknown_size', """
typedef char opaque_t[6];
@@ -1014,7 +1015,7 @@
def test_call_with_incomplete_structs():
ffi = FFI()
ffi.cdef("typedef struct {...;} foo_t; "
- "foo_t myglob; "
+ "extern foo_t myglob; "
"foo_t increment(foo_t s); "
"double getx(foo_t s);")
lib = verify(ffi, 'test_call_with_incomplete_structs', """
@@ -1058,7 +1059,7 @@
def test_global_var_array_2():
ffi = FFI()
- ffi.cdef("int a[...][...];")
+ ffi.cdef("extern int a[...][...];")
lib = verify(ffi, 'test_global_var_array_2', 'int a[10][8];')
lib.a[9][7] = 123456
assert lib.a[9][7] == 123456
@@ -1071,7 +1072,7 @@
def test_global_var_array_3():
ffi = FFI()
- ffi.cdef("int a[][...];")
+ ffi.cdef("extern int a[][...];")
lib = verify(ffi, 'test_global_var_array_3', 'int a[10][8];')
lib.a[9][7] = 123456
assert lib.a[9][7] == 123456
@@ -1082,7 +1083,7 @@
def test_global_var_array_4():
ffi = FFI()
- ffi.cdef("int a[10][...];")
+ ffi.cdef("extern int a[10][...];")
lib = verify(ffi, 'test_global_var_array_4', 'int a[10][8];')
lib.a[9][7] = 123456
assert lib.a[9][7] == 123456
@@ -1205,7 +1206,7 @@
def test_import_from_lib():
ffi = FFI()
- ffi.cdef("int mybar(int); int myvar;\n#define MYFOO ...")
+ ffi.cdef("int mybar(int); static int myvar;\n#define MYFOO ...")
lib = verify(ffi, 'test_import_from_lib',
"#define MYFOO 42\n"
"static int mybar(int x) { return x + 1; }\n"
@@ -1221,7 +1222,7 @@
def test_macro_var_callback():
ffi = FFI()
- ffi.cdef("int my_value; int *(*get_my_value)(void);")
+ ffi.cdef("extern int my_value; extern int *(*get_my_value)(void);")
lib = verify(ffi, 'test_macro_var_callback',
"int *(*get_my_value)(void);\n"
"#define my_value (*get_my_value())")
@@ -1336,7 +1337,7 @@
def test_const_function_type_args():
ffi = FFI()
- ffi.cdef("""int (*foobar)(const int a, const int *b, const int c[]);""")
+ ffi.cdef("""extern int(*foobar)(const int a,const int*b,const int c[]);""")
lib = verify(ffi, 'test_const_function_type_args', """
int (*foobar)(const int a, const int *b, const int c[]);
""")
@@ -1626,7 +1627,7 @@
def test_extern_python_bogus_name():
ffi = FFI()
- ffi.cdef("int abc;")
+ ffi.cdef("extern int abc;")
lib = verify(ffi, 'test_extern_python_bogus_name', "int abc;")
def fn():
pass
@@ -1787,8 +1788,8 @@
ffi.cdef("""
extern "Python" int __stdcall foo(int);
extern "Python" int WINAPI bar(int);
- int (__stdcall * mycb1)(int);
- int indirect_call(int);
+ static int (__stdcall * mycb1)(int);
+ static int indirect_call(int);
""")
lib = verify(ffi, 'test_extern_python_stdcall', """
#ifndef _MSC_VER
@@ -1856,7 +1857,7 @@
def test_introspect_global_var():
ffi = FFI()
- ffi.cdef("float g1;")
+ ffi.cdef("extern float g1;")
lib = verify(ffi, 'test_introspect_global_var', """
float g1;
""")
@@ -1867,7 +1868,7 @@
def test_introspect_global_var_array():
ffi = FFI()
- ffi.cdef("float g1[100];")
+ ffi.cdef("extern float g1[100];")
lib = verify(ffi, 'test_introspect_global_var_array', """
float g1[100];
""")
@@ -2039,7 +2040,7 @@
ffi.cdef("float _Complex f1(float a, float b);");
lib = verify(ffi, "test_function_returns_float_complex", """
#include <complex.h>
- static float _Complex f1(float a, float b) { return a + I*2.0*b; }
+ static float _Complex f1(float a, float b) { return a + I*2.0f*b; }
""", no_cpp=True) # <complex.h> fails on some systems with C++
result = lib.f1(1.25, 5.1)
assert type(result) == complex
@@ -2090,7 +2091,7 @@
ffi = FFI()
ffi.cdef("""
typedef int foo_t[...], bar_t[...];
- int gv[...];
+ extern int gv[...];
typedef int mat_t[...][...];
typedef int vmat_t[][...];
""")
diff --git a/extra_tests/cffi_tests/cffi1/test_verify1.py
b/extra_tests/cffi_tests/cffi1/test_verify1.py
--- a/extra_tests/cffi_tests/cffi1/test_verify1.py
+++ b/extra_tests/cffi_tests/cffi1/test_verify1.py
@@ -5,7 +5,7 @@
from cffi import CDefError
from cffi import recompiler
from extra_tests.cffi_tests.support import *
-from extra_tests.cffi_tests.support import _verify
+from extra_tests.cffi_tests.support import _verify, extra_compile_args
import _cffi_backend
lib_m = ['m']
@@ -14,18 +14,6 @@
import distutils.ccompiler
if distutils.ccompiler.get_default_compiler() == 'msvc':
lib_m = ['msvcrt']
- extra_compile_args = [] # no obvious -Werror equivalent on MSVC
-else:
- if (sys.platform == 'darwin' and
- [int(x) for x in os.uname()[2].split('.')] >= [11, 0, 0]):
- # assume a standard clang or gcc
- extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion']
- # special things for clang
- extra_compile_args.append('-Qunused-arguments')
- else:
- # assume a standard gcc
- extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion',
- '-Wno-unused-parameter']
class FFI(FFI):
error = _cffi_backend.FFI.error
@@ -268,7 +256,7 @@
def test_var_signed_integer_types():
ffi = FFI()
lst = all_signed_integer_types(ffi)
- csource = "\n".join(["%s somevar_%s;" % (tp, tp.replace(' ', '_'))
+ csource = "\n".join(["static %s somevar_%s;" % (tp, tp.replace(' ', '_'))
for tp in lst])
ffi.cdef(csource)
lib = ffi.verify(csource)
@@ -287,7 +275,7 @@
def test_var_unsigned_integer_types():
ffi = FFI()
lst = all_unsigned_integer_types(ffi)
- csource = "\n".join(["%s somevar_%s;" % (tp, tp.replace(' ', '_'))
+ csource = "\n".join(["static %s somevar_%s;" % (tp, tp.replace(' ', '_'))
for tp in lst])
ffi.cdef(csource)
lib = ffi.verify(csource)
@@ -791,8 +779,8 @@
def test_access_variable():
ffi = FFI()
- ffi.cdef("int foo(void);\n"
- "int somenumber;")
+ ffi.cdef("static int foo(void);\n"
+ "static int somenumber;")
lib = ffi.verify("""
static int somenumber = 2;
static int foo(void) {
@@ -809,7 +797,7 @@
def test_access_address_of_variable():
# access the address of 'somenumber': need a trick
ffi = FFI()
- ffi.cdef("int somenumber; static int *const somenumberptr;")
+ ffi.cdef("static int somenumber; static int *const somenumberptr;")
lib = ffi.verify("""
static int somenumber = 2;
#define somenumberptr (&somenumber)
@@ -821,8 +809,8 @@
def test_access_array_variable(length=5):
ffi = FFI()
- ffi.cdef("int foo(int);\n"
- "int somenumber[%s];" % (length,))
+ ffi.cdef("static int foo(int);\n"
+ "static int somenumber[%s];" % (length,))
lib = ffi.verify("""
static int somenumber[] = {2, 2, 3, 4, 5};
static int foo(int i) {
@@ -853,8 +841,8 @@
def test_access_struct_variable():
ffi = FFI()
ffi.cdef("struct foo { int x; ...; };\n"
- "int foo(int);\n"
- "struct foo stuff;")
+ "static int foo(int);\n"
+ "static struct foo stuff;")
lib = ffi.verify("""
struct foo { int x, y, z; };
static struct foo stuff = {2, 5, 8};
@@ -878,9 +866,9 @@
def test_access_callback():
ffi = FFI()
- ffi.cdef("int (*cb)(int);\n"
- "int foo(int);\n"
- "void reset_cb(void);")
+ ffi.cdef("static int (*cb)(int);\n"
+ "static int foo(int);\n"
+ "static void reset_cb(void);")
lib = ffi.verify("""
static int g(int x) { return x * 7; }
static int (*cb)(int);
@@ -896,9 +884,9 @@
def test_access_callback_function_typedef():
ffi = FFI()
ffi.cdef("typedef int mycallback_t(int);\n"
- "mycallback_t *cb;\n"
- "int foo(int);\n"
- "void reset_cb(void);")
+ "static mycallback_t *cb;\n"
+ "static int foo(int);\n"
+ "static void reset_cb(void);")
lib = ffi.verify("""
static int g(int x) { return x * 7; }
static int (*cb)(int);
@@ -1039,7 +1027,7 @@
def test_autofilled_struct_as_argument_dynamic():
ffi = FFI()
ffi.cdef("struct foo_s { long a; ...; };\n"
- "int (*foo)(struct foo_s);")
+ "static int (*foo)(struct foo_s);")
lib = ffi.verify("""
struct foo_s {
double b;
@@ -1048,7 +1036,7 @@
int foo1(struct foo_s s) {
return (int)s.a - (int)s.b;
}
- int (*foo)(struct foo_s s) = &foo1;
+ static int (*foo)(struct foo_s s) = &foo1;
""")
e = py.test.raises(NotImplementedError, lib.foo, "?")
msg = ("ctype 'struct foo_s' not supported as argument. It is a struct "
@@ -1424,7 +1412,7 @@
py.test.skip("_Bool not in MSVC")
ffi = FFI()
ffi.cdef("struct foo_s { _Bool x; };"
- "_Bool foo(_Bool); _Bool (*foop)(_Bool);")
+ "_Bool foo(_Bool); static _Bool (*foop)(_Bool);")
lib = ffi.verify("""
struct foo_s { _Bool x; };
int foo(int arg) {
@@ -1433,7 +1421,7 @@
_Bool _foofunc(_Bool x) {
return !x;
}
- _Bool (*foop)(_Bool) = _foofunc;
+ static _Bool (*foop)(_Bool) = _foofunc;
""")
p = ffi.new("struct foo_s *")
p.x = 1
@@ -1618,7 +1606,7 @@
def test_FILE_stored_explicitly():
ffi = FFI()
- ffi.cdef("int myprintf11(const char *, int); FILE *myfile;")
+ ffi.cdef("int myprintf11(const char *, int); extern FILE *myfile;")
lib = ffi.verify("""
#include <stdio.h>
FILE *myfile;
@@ -1644,13 +1632,13 @@
def test_global_array_with_missing_length():
ffi = FFI()
- ffi.cdef("int fooarray[];")
+ ffi.cdef("extern int fooarray[];")
lib = ffi.verify("int fooarray[50];")
assert repr(lib.fooarray).startswith("<cdata 'int *'")
def test_global_array_with_dotdotdot_length():
ffi = FFI()
- ffi.cdef("int fooarray[...];")
+ ffi.cdef("extern int fooarray[...];")
lib = ffi.verify("int fooarray[50];")
assert repr(lib.fooarray).startswith("<cdata 'int[50]'")
@@ -1658,7 +1646,7 @@
py.test.xfail("was detected only because 23 bytes cannot be divided by 4; "
"redo more generally")
ffi = FFI()
- ffi.cdef("int fooarray[...];")
+ ffi.cdef("extern int fooarray[...];")
py.test.raises(VerificationError, ffi.verify, "char fooarray[23];")
def test_struct_containing_struct():
@@ -1779,7 +1767,7 @@
def test_callback_indirection():
ffi = FFI()
ffi.cdef("""
- int (*python_callback)(int how_many, int *values);
+ static int (*python_callback)(int how_many, int *values);
int (*const c_callback)(int,...); /* pass this ptr to C routines */
int some_c_function(int(*cb)(int,...));
""")
@@ -1913,23 +1901,23 @@
def test_bug_const_char_ptr_array_1():
ffi = FFI()
- ffi.cdef("""const char *a[...];""")
+ ffi.cdef("""extern const char *a[...];""")
lib = ffi.verify("""const char *a[5];""")
assert repr(ffi.typeof(lib.a)) == "<ctype 'char *[5]'>"
def test_bug_const_char_ptr_array_2():
ffi = FFI()
- ffi.cdef("""const int a[];""")
+ ffi.cdef("""extern const int a[];""")
lib = ffi.verify("""const int a[5];""")
assert repr(ffi.typeof(lib.a)) == "<ctype 'int *'>"
def _test_various_calls(force_libffi):
cdef_source = """
- int xvalue;
- long long ivalue, rvalue;
- float fvalue;
- double dvalue;
- long double Dvalue;
+ extern int xvalue;
+ extern long long ivalue, rvalue;
+ extern float fvalue;
+ extern double dvalue;
+ extern long double Dvalue;
signed char tf_bb(signed char x, signed char c);
unsigned char tf_bB(signed char x, unsigned char c);
short tf_bh(signed char x, short c);
@@ -2112,7 +2100,7 @@
old = sys.getdlopenflags()
try:
ffi1 = FFI()
- ffi1.cdef("int foo_verify_dlopen_flags_1;")
+ ffi1.cdef("extern int foo_verify_dlopen_flags_1;")
sys.setdlopenflags(ffi1.RTLD_GLOBAL | ffi1.RTLD_NOW)
lib1 = ffi1.verify("int foo_verify_dlopen_flags_1;")
finally:
@@ -2253,7 +2241,7 @@
def test_macro_var():
ffi = FFI()
- ffi.cdef("int myarray[50], my_value;")
+ ffi.cdef("extern int myarray[50], my_value;")
lib = ffi.verify("""
int myarray[50];
int *get_my_value(void) {
diff --git a/extra_tests/cffi_tests/embedding/add1.py
b/extra_tests/cffi_tests/embedding/add1.py
--- a/extra_tests/cffi_tests/embedding/add1.py
+++ b/extra_tests/cffi_tests/embedding/add1.py
@@ -12,7 +12,11 @@
sys.stdout.write("preparing")
for i in range(3):
sys.stdout.flush()
- time.sleep(0.2)
+ # Windows: sometimes time.sleep() doesn't sleep at all.
+ # This appears to occur on recent versions of python only.
+ t_end = time.time() + 0.19
+ while time.time() < t_end:
+ time.sleep(0.2)
sys.stdout.write(".")
sys.stdout.write("\n")
diff --git a/extra_tests/cffi_tests/embedding/add_recursive.py
b/extra_tests/cffi_tests/embedding/add_recursive.py
--- a/extra_tests/cffi_tests/embedding/add_recursive.py
+++ b/extra_tests/cffi_tests/embedding/add_recursive.py
@@ -4,7 +4,7 @@
ffi = cffi.FFI()
ffi.embedding_api("""
- int (*my_callback)(int);
+ extern int (*my_callback)(int);
int add_rec(int, int);
""")
diff --git a/extra_tests/cffi_tests/embedding/test_thread.py
b/extra_tests/cffi_tests/embedding/test_thread.py
--- a/extra_tests/cffi_tests/embedding/test_thread.py
+++ b/extra_tests/cffi_tests/embedding/test_thread.py
@@ -22,17 +22,21 @@
add1_cffi = self.prepare_module('add1')
add2_cffi = self.prepare_module('add2')
self.compile('thread2-test', [add1_cffi, add2_cffi], threads=True)
- output = self.execute('thread2-test')
- output = self._take_out(output, "preparing")
- output = self._take_out(output, ".")
- output = self._take_out(output, ".")
- # at least the 3rd dot should be after everything from ADD2
- assert output == ("starting\n"
- "prepADD2\n"
- "adding 1000 and 200 and 30\n"
- ".\n"
- "adding 40 and 2\n"
- "done\n")
+ for i in range(3):
+ output = self.execute('thread2-test')
+ print('='*79)
+ print(output)
+ print('='*79)
+ output = self._take_out(output, "preparing")
+ output = self._take_out(output, ".")
+ output = self._take_out(output, ".")
+ # at least the 3rd dot should be after everything from ADD2
+ assert output == ("starting\n"
+ "prepADD2\n"
+ "adding 1000 and 200 and 30\n"
+ ".\n"
+ "adding 40 and 2\n"
+ "done\n")
def test_alt_issue(self):
add1_cffi = self.prepare_module('add1')
diff --git a/extra_tests/cffi_tests/support.py
b/extra_tests/cffi_tests/support.py
--- a/extra_tests/cffi_tests/support.py
+++ b/extra_tests/cffi_tests/support.py
@@ -1,5 +1,5 @@
# Generated by pypy/tool/import_cffi.py
-import sys
+import sys, os
if sys.version_info < (3,):
__all__ = ['u']
@@ -87,3 +87,24 @@
if not name.startswith('_') and not hasattr(module.ffi, name):
setattr(ffi, name, NotImplemented)
return module.lib
+
+
+# For testing, we call gcc with "-Werror". This is fragile because newer
+# versions of gcc are always better at producing warnings, particularly for
+# auto-generated code. We need here to adapt and silence them as needed.
+
+if sys.platform == 'win32':
+ extra_compile_args = [] # no obvious -Werror equivalent on MSVC
+else:
+ if (sys.platform == 'darwin' and
+ [int(x) for x in os.uname()[2].split('.')] >= [11, 0, 0]):
+ # assume a standard clang or gcc
+ extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion',
+ '-Wno-unreachable-code']
+ # special things for clang
+ extra_compile_args.append('-Qunused-arguments')
+ else:
+ # assume a standard gcc
+ extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion',
+ '-Wno-unused-parameter',
+ '-Wno-unreachable-code']
diff --git a/extra_tests/cffi_tests/test_version.py
b/extra_tests/cffi_tests/test_version.py
--- a/extra_tests/cffi_tests/test_version.py
+++ b/extra_tests/cffi_tests/test_version.py
@@ -1,7 +1,7 @@
from email.parser import Parser
import py
-import urllib2
+from urllib.request import urlopen
import cffi
import pypy
@@ -14,9 +14,8 @@
def test_pycparser_version():
url =
'https://raw.githubusercontent.com/eliben/pycparser/master/pycparser/__init__.py'
- source = urllib2.urlopen(url).read()
+ source = urlopen(url).read().decode('utf8')
dest = py.path.local(__file__).join('..', '..', '..', 'lib_pypy', 'cffi',
'_pycparser', '__init__.py').read()
# if this fails, the vendored pycparser is not the latest version
assert source.strip() == dest.strip()
-
diff --git a/pypy/module/_asyncio/test/test_asyncio.py
b/extra_tests/test_asyncio.py
rename from pypy/module/_asyncio/test/test_asyncio.py
rename to extra_tests/test_asyncio.py
--- a/pypy/module/_asyncio/test/test_asyncio.py
+++ b/extra_tests/test_asyncio.py
@@ -1,116 +1,96 @@
import sys
-class AppTestAsyncIO(object):
- """These tests are based on the async-await syntax of Python 3.5."""
-
- spaceconfig = dict(usemodules=["select","_socket","thread","signal",
- "struct","_multiprocessing","array",
- "_posixsubprocess",
- "unicodedata"])
- if sys.platform == 'win32':
- pass
- else:
- spaceconfig['usemodules'].append('fcntl')
-
- def test_gil_issue(self):
- # the problem occured at await asyncio.open_connection
- # after calling run_until_complete
- """
import encodings.idna
import asyncio
-async def f():
- reader, writer = await asyncio.open_connection('example.com', 80)
- writer.close()
+def test_async_gil_issue():
+ async def f():
+ reader, writer = await asyncio.open_connection('example.com', 80)
+ writer.close()
-loop = asyncio.get_event_loop()
-loop.run_until_complete(f())
- """
+ loop = asyncio.get_event_loop()
+ loop.run_until_complete(f())
- def test_async_for(self):
- # tests if async for receives all stores values in the right order
- # and if the correct methods __aiter__ and __anext__ get called
- # and if the end results of run_until_complete are None (in a tuple)
- """
-import asyncio
+def test_async_for():
+ # tests if async for receives all stores values in the right order
+ # and if the correct methods __aiter__ and __anext__ get called
+ # and if the end results of run_until_complete are None (in a tuple)
+ import asyncio
-class AsyncIter:
- def __init__(self):
- self._data = list(range(5))
- self._index = 0
+ class AsyncIter:
+ def __init__(self):
+ self._data = list(range(5))
+ self._index = 0
+
+ async def __aiter__(self):
+ return self
+
+ async def __anext__(self):
+ while self._index < 5:
+ await asyncio.sleep(1)
+ self._index += 1
+ return self._data[self._index-1]
+ raise StopAsyncIteration
+
+ class Corotest(object):
+ def __init__(self):
+ self.res = "-"
+
+ async def do_loop(self):
+ async for x in AsyncIter():
+ self.res += str(x)
+ self.res += "-"
+
+ cor = Corotest()
+ loop = asyncio.get_event_loop()
+ futures = [asyncio.ensure_future(cor.do_loop()),
asyncio.ensure_future(cor.do_loop())]
+ taskres = loop.run_until_complete(asyncio.wait(futures))
+ assert cor.res.count('0') == 2
+ assert cor.res.count('1') == 2
+ assert cor.res.count('2') == 2
+ assert cor.res.count('3') == 2
+ assert cor.res.count('4') == 2
+ assert cor.res.find("0") < cor.res.find("1")
+ assert cor.res.find("1") < cor.res.find("2")
+ assert cor.res.find("2") < cor.res.find("3")
+ assert cor.res.find("3") < cor.res.find("4")
+ assert isinstance(taskres, tuple)
+ assert len(taskres) == 2
+ assert "result=None" in repr(taskres[0].pop())
+ assert "result=None" in repr(taskres[0].pop())
- async def __aiter__(self):
- return self
-
- async def __anext__(self):
- while self._index < 5:
- await asyncio.sleep(1)
- self._index += 1
- return self._data[self._index-1]
- raise StopAsyncIteration
+def test_asynchronous_context_managers():
+ # it is important that "releasing lock A" happens before "holding lock B"
+ # or the other way around, but it is not allowed that both coroutines
+ # hold the lock at the same time
+ import encodings.idna
+ import asyncio
-class Corotest(object):
- def __init__(self):
- self.res = "-"
-
- async def do_loop(self):
- async for x in AsyncIter():
- self.res += str(x)
- self.res += "-"
+ class Corotest(object):
+ def __init__(self):
+ self.res = "-"
+
+ async def coro(self, name, lock):
+ self.res += ' coro {}: waiting for lock -'.format(name)
+ async with lock:
+ self.res += ' coro {}: holding the lock -'.format(name)
+ await asyncio.sleep(1)
+ self.res += ' coro {}: releasing the lock -'.format(name)
-cor = Corotest()
-loop = asyncio.get_event_loop()
-futures = [asyncio.ensure_future(cor.do_loop()),
asyncio.ensure_future(cor.do_loop())]
-taskres = loop.run_until_complete(asyncio.wait(futures))
-assert cor.res.count('0') == 2
-assert cor.res.count('1') == 2
-assert cor.res.count('2') == 2
-assert cor.res.count('3') == 2
-assert cor.res.count('4') == 2
-assert cor.res.find("0") < cor.res.find("1")
-assert cor.res.find("1") < cor.res.find("2")
-assert cor.res.find("2") < cor.res.find("3")
-assert cor.res.find("3") < cor.res.find("4")
-assert isinstance(taskres, tuple)
-assert len(taskres) == 2
-assert "result=None" in repr(taskres[0].pop())
-assert "result=None" in repr(taskres[0].pop())
- """
-
- def test_asynchronous_context_managers(self):
- # it is important that "releasing lock A" happens before "holding lock
B"
- # or the other way around, but it is not allowed that both coroutines
- # hold the lock at the same time
- """
-import encodings.idna
-import asyncio
+ cor = Corotest()
+ loop = asyncio.get_event_loop()
+ lock = asyncio.Lock()
+ coros = asyncio.gather(cor.coro(1, lock), cor.coro(2, lock))
+ try:
+ loop.run_until_complete(coros)
+ finally:
+ loop.close()
-class Corotest(object):
- def __init__(self):
- self.res = "-"
-
- async def coro(self, name, lock):
- self.res += ' coro {}: waiting for lock -'.format(name)
- async with lock:
- self.res += ' coro {}: holding the lock -'.format(name)
- await asyncio.sleep(1)
- self.res += ' coro {}: releasing the lock -'.format(name)
-
-cor = Corotest()
-loop = asyncio.get_event_loop()
-lock = asyncio.Lock()
-coros = asyncio.gather(cor.coro(1, lock), cor.coro(2, lock))
-try:
- loop.run_until_complete(coros)
-finally:
- loop.close()
-
-assert "coro 1: waiting for lock" in cor.res
-assert "coro 1: holding the lock" in cor.res
-assert "coro 1: releasing the lock" in cor.res
-assert "coro 2: waiting for lock" in cor.res
-assert "coro 2: holding the lock" in cor.res
-assert "coro 2: releasing the lock" in cor.res
-assert cor.res.find("coro 1: releasing the lock") < cor.res.find("coro 2:
holding the lock") or \
-cor.res.find("coro 2: releasing the lock") < cor.res.find("coro 1: holding the
lock")
- """
+ assert "coro 1: waiting for lock" in cor.res
+ assert "coro 1: holding the lock" in cor.res
+ assert "coro 1: releasing the lock" in cor.res
+ assert "coro 2: waiting for lock" in cor.res
+ assert "coro 2: holding the lock" in cor.res
+ assert "coro 2: releasing the lock" in cor.res
+ assert cor.res.find("coro 1: releasing the lock") < cor.res.find("coro 2:
holding the lock") or \
+ cor.res.find("coro 2: releasing the lock") < cor.res.find("coro 1: holding
the lock")
diff --git a/extra_tests/test_pyrepl/infrastructure.py
b/extra_tests/test_pyrepl/infrastructure.py
--- a/extra_tests/test_pyrepl/infrastructure.py
+++ b/extra_tests/test_pyrepl/infrastructure.py
@@ -59,6 +59,11 @@
return Event(*ev)
+ def getpending(self):
+ """Nothing pending, but do not return None here."""
+ return Event('key', '', b'')
+
+
class BaseTestReader(Reader):
def get_prompt(self, lineno, cursor_on_line):
diff --git a/extra_tests/test_pyrepl/test_readline.py
b/extra_tests/test_pyrepl/test_readline.py
--- a/extra_tests/test_pyrepl/test_readline.py
+++ b/extra_tests/test_pyrepl/test_readline.py
@@ -15,8 +15,7 @@
os.write(master, b'input\n')
with sane_term():
- result = readline_wrapper.get_reader().readline()
- #result = readline_wrapper.raw_input('prompt:')
+ result = readline_wrapper.raw_input('prompt:')
assert result == 'input'
# A bytes string on python2, a unicode string on python3.
assert isinstance(result, str)
diff --git a/extra_tests/test_pyrepl/test_wishes.py
b/extra_tests/test_pyrepl/test_wishes.py
--- a/extra_tests/test_pyrepl/test_wishes.py
+++ b/extra_tests/test_pyrepl/test_wishes.py
@@ -27,5 +27,5 @@
read_spec([
(('digit-arg', '3'), ['']),
(('quoted-insert', None), ['']),
- (('self-insert', '\033'), ['^[^[^[']),
+ (('key', '\033'), ['^[^[^[']),
(('accept', None), None)])
diff --git a/extra_tests/test_semlock.py b/extra_tests/test_semlock.py
--- a/extra_tests/test_semlock.py
+++ b/extra_tests/test_semlock.py
@@ -1,6 +1,6 @@
from _multiprocessing import SemLock
from threading import Thread
-import thread
+import _thread
import time
@@ -23,7 +23,7 @@
for t in threads:
try:
t.start()
- except thread.error:
+ except _thread.error:
# too many threads for this system
t.started = False
n_started -= 1
diff --git a/lib-python/3/_osx_support.py b/lib-python/3/_osx_support.py
--- a/lib-python/3/_osx_support.py
+++ b/lib-python/3/_osx_support.py
@@ -109,7 +109,7 @@
# else: fall back to the default behaviour
if not _SYSTEM_VERSION:
# minimum supported MACOSX_DEPLOYMENT_TARGET version
- return '10.14'
+ return '10.7'
return _SYSTEM_VERSION
def _remove_original_values(_config_vars):
diff --git a/lib-python/3/datetime.py b/lib-python/3/datetime.py
--- a/lib-python/3/datetime.py
+++ b/lib-python/3/datetime.py
@@ -609,31 +609,31 @@
if isinstance(other, timedelta):
return self._cmp(other) == 0
else:
- return False
+ return NotImplemented
def __le__(self, other):
if isinstance(other, timedelta):
return self._cmp(other) <= 0
else:
- _cmperror(self, other)
+ return NotImplemented
def __lt__(self, other):
if isinstance(other, timedelta):
return self._cmp(other) < 0
else:
- _cmperror(self, other)
+ return NotImplemented
def __ge__(self, other):
if isinstance(other, timedelta):
return self._cmp(other) >= 0
else:
- _cmperror(self, other)
+ return NotImplemented
def __gt__(self, other):
if isinstance(other, timedelta):
return self._cmp(other) > 0
else:
- _cmperror(self, other)
+ return NotImplemented
def _cmp(self, other):
assert isinstance(other, timedelta)
@@ -1144,31 +1144,31 @@
if isinstance(other, time):
return self._cmp(other, allow_mixed=True) == 0
else:
- return False
+ return NotImplemented
def __le__(self, other):
if isinstance(other, time):
return self._cmp(other) <= 0
else:
- _cmperror(self, other)
+ return NotImplemented
def __lt__(self, other):
if isinstance(other, time):
return self._cmp(other) < 0
else:
- _cmperror(self, other)
+ return NotImplemented
def __ge__(self, other):
if isinstance(other, time):
return self._cmp(other) >= 0
else:
- _cmperror(self, other)
+ return NotImplemented
def __gt__(self, other):
if isinstance(other, time):
return self._cmp(other) > 0
else:
- _cmperror(self, other)
+ return NotImplemented
def _cmp(self, other, allow_mixed=False):
assert isinstance(other, time)
@@ -2048,9 +2048,9 @@
return (self._offset, self._name)
def __eq__(self, other):
- if type(other) != timezone:
- return False
- return self._offset == other._offset
+ if isinstance(other, timezone):
+ return self._offset == other._offset
+ return NotImplemented
def __hash__(self):
return hash(self._offset)
diff --git a/lib-python/3/distutils/command/build_ext.py
b/lib-python/3/distutils/command/build_ext.py
--- a/lib-python/3/distutils/command/build_ext.py
+++ b/lib-python/3/distutils/command/build_ext.py
@@ -28,11 +28,6 @@
from distutils.ccompiler import show_compilers
show_compilers()
-def _get_c_extension_suffix():
- import importlib
- suffixes = importlib.machinery.EXTENSION_SUFFIXES
- return suffixes[0] if suffixes else None
-
class build_ext(Command):
@@ -686,15 +681,7 @@
"""
from distutils.sysconfig import get_config_var
ext_path = ext_name.split('.')
- # PyPy tweak: first try to get the C extension suffix from
- # 'imp'. If it fails we fall back to the 'SO' config var, like
- # the previous version of this code did. This should work for
- # CPython too. The point is that on PyPy with cpyext, the
- # config var 'SO' is just ".so" but we want to return
- # ".pypy-VERSION.so" instead.
- ext_suffix = _get_c_extension_suffix()
- if ext_suffix is None:
- ext_suffix = get_config_var('EXT_SUFFIX') # fall-back
+ ext_suffix = get_config_var('EXT_SUFFIX')
return os.path.join(*ext_path) + ext_suffix
def get_export_symbols(self, ext):
diff --git a/lib-python/3/ensurepip/__init__.py
b/lib-python/3/ensurepip/__init__.py
--- a/lib-python/3/ensurepip/__init__.py
+++ b/lib-python/3/ensurepip/__init__.py
@@ -8,9 +8,9 @@
__all__ = ["version", "bootstrap"]
-_SETUPTOOLS_VERSION = "40.6.2"
+_SETUPTOOLS_VERSION = "41.2.0"
-_PIP_VERSION = "18.1"
+_PIP_VERSION = "19.2.3"
_PROJECTS = [
("setuptools", _SETUPTOOLS_VERSION),
diff --git a/lib-python/3/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl
b/lib-python/3/ensurepip/_bundled/pip-18.1-py2.py3-none-any.whl
deleted file mode 100644
index
c3c146f6da272399a19fd6e21364a4f45066cec7..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
[cut]
diff --git a/lib-python/3/ensurepip/_bundled/pip-19.2.3-py2.py3-none-any.whl
b/lib-python/3/ensurepip/_bundled/pip-19.2.3-py2.py3-none-any.whl
new file mode 100644
index
e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8118df8ac1940f8c6cb410fbc18e5fae59872b95
GIT binary patch
[cut]
diff --git
a/lib-python/3/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl
b/lib-python/3/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl
deleted file mode 100644
index
4c8a619571d1e50ae8b6b961a4bebc32c90694e1..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
[cut]
diff --git
a/lib-python/3/ensurepip/_bundled/setuptools-41.2.0-py2.py3-none-any.whl
b/lib-python/3/ensurepip/_bundled/setuptools-41.2.0-py2.py3-none-any.whl
new file mode 100644
index
e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..82df6f63f4ee97380af0a29d8825ae775333b86d
GIT binary patch
[cut]
diff --git a/lib-python/3/sysconfig.py b/lib-python/3/sysconfig.py
--- a/lib-python/3/sysconfig.py
+++ b/lib-python/3/sysconfig.py
@@ -450,6 +450,10 @@
vars['EXE'] = '.exe'
vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))
+ # pypy: give us control over the ABI tag in a wheel name
+ import _imp
+ so_ext = _imp.extension_suffixes()[0]
+ vars['SOABI']= '-'.join(so_ext.split('.')[1].split('-')[:2])
#
# public APIs
diff --git a/lib-python/3/test/test_asyncio/test_events.py
b/lib-python/3/test/test_asyncio/test_events.py
--- a/lib-python/3/test/test_asyncio/test_events.py
+++ b/lib-python/3/test/test_asyncio/test_events.py
@@ -932,9 +932,14 @@
server = self.loop.run_until_complete(f)
self.assertEqual(len(server.sockets), 1)
sock = server.sockets[0]
- self.assertFalse(
- sock.getsockopt(
- socket.SOL_SOCKET, socket.SO_REUSEPORT))
+ try:
+ self.assertFalse(
+ sock.getsockopt(
+ socket.SOL_SOCKET, socket.SO_REUSEPORT))
+ except OSError:
+ # SO_REUSEPORT is not actually supported, bail!
+ server.close()
+ return
server.close()
test_utils.run_briefly(self.loop)
diff --git a/lib-python/3/test/test_bdb.py b/lib-python/3/test/test_bdb.py
--- a/lib-python/3/test/test_bdb.py
+++ b/lib-python/3/test/test_bdb.py
@@ -726,7 +726,7 @@
('line', 2, 'tfunc_import'), ('step', ),
('line', 3, 'tfunc_import'), ('quit', ),
]
- skip = ('importlib*', TEST_MODULE)
+ skip = ('importlib*', '_structseq', TEST_MODULE)
with TracerRun(self, skip=skip) as tracer:
tracer.runcall(tfunc_import)
diff --git a/lib-python/3/test/test_dis.py b/lib-python/3/test/test_dis.py
--- a/lib-python/3/test/test_dis.py
+++ b/lib-python/3/test/test_dis.py
@@ -262,7 +262,7 @@
20 RETURN_VALUE
"""
-# XXX: change for PyPy?
+# changed for PyPy
dis_traceback = """\
%3d 0 SETUP_EXCEPT 12 (to 14)
@@ -280,18 +280,18 @@
22 POP_TOP
24 STORE_FAST 0 (e)
26 POP_TOP
- 28 SETUP_FINALLY 12 (to 42)
+ 28 SETUP_FINALLY 10 (to 40)
%3d 30 LOAD_FAST 0 (e)
32 LOAD_ATTR 1 (__traceback__)
34 STORE_FAST 1 (tb)
36 POP_BLOCK
- 38 POP_EXCEPT
- 40 LOAD_CONST 0 (None)
- >> 42 LOAD_CONST 0 (None)
- 44 STORE_FAST 0 (e)
- 46 DELETE_FAST 0 (e)
- 48 END_FINALLY
+ 38 LOAD_CONST 0 (None)
+ >> 40 LOAD_CONST 0 (None)
+ 42 STORE_FAST 0 (e)
+ 44 DELETE_FAST 0 (e)
+ 46 END_FINALLY
+ 48 POP_EXCEPT
50 JUMP_FORWARD 2 (to 54)
>> 52 END_FINALLY
@@ -686,9 +686,9 @@
# End fodder for opinfo generation tests
expected_outer_line = 1
_line_offset = outer.__code__.co_firstlineno - 1
-code_object_f = outer.__code__.co_consts[3]
+code_object_f = outer.__code__.co_consts[2]
expected_f_line = code_object_f.co_firstlineno - _line_offset
-code_object_inner = code_object_f.co_consts[3]
+code_object_inner = code_object_f.co_consts[2]
expected_inner_line = code_object_inner.co_firstlineno - _line_offset
expected_jumpy_line = 1
@@ -713,22 +713,22 @@
Instruction = dis.Instruction
expected_opinfo_outer = [
- Instruction(opname='LOAD_CONST', opcode=100, arg=8, argval=(3, 4),
argrepr='(3, 4)', offset=0, starts_line=2, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=1, argval=(3, 4),
argrepr='(3, 4)', offset=0, starts_line=2, is_jump_target=False),
Instruction(opname='LOAD_CLOSURE', opcode=135, arg=0, argval='a',
argrepr='a', offset=2, starts_line=None, is_jump_target=False),
Instruction(opname='LOAD_CLOSURE', opcode=135, arg=1, argval='b',
argrepr='b', offset=4, starts_line=None, is_jump_target=False),
Instruction(opname='BUILD_TUPLE', opcode=102, arg=2, argval=2, argrepr='',
offset=6, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=3, argval=code_object_f,
argrepr=repr(code_object_f), offset=8, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=4,
argval='outer.<locals>.f', argrepr="'outer.<locals>.f'", offset=10,
starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=2, argval=code_object_f,
argrepr=repr(code_object_f), offset=8, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=3,
argval='outer.<locals>.f', argrepr="'outer.<locals>.f'", offset=10,
starts_line=None, is_jump_target=False),
Instruction(opname='MAKE_FUNCTION', opcode=132, arg=9, argval=9, argrepr='',
offset=12, starts_line=None, is_jump_target=False),
Instruction(opname='STORE_FAST', opcode=125, arg=2, argval='f', argrepr='f',
offset=14, starts_line=None, is_jump_target=False),
Instruction(opname='LOAD_GLOBAL', opcode=116, arg=0, argval='print',
argrepr='print', offset=16, starts_line=7, is_jump_target=False),
Instruction(opname='LOAD_DEREF', opcode=136, arg=0, argval='a', argrepr='a',
offset=18, starts_line=None, is_jump_target=False),
Instruction(opname='LOAD_DEREF', opcode=136, arg=1, argval='b', argrepr='b',
offset=20, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval='', argrepr="''",
offset=22, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=6, argval=1, argrepr='1',
offset=24, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=4, argval='', argrepr="''",
offset=22, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval=1, argrepr='1',
offset=24, starts_line=None, is_jump_target=False),
Instruction(opname='BUILD_LIST', opcode=103, arg=0, argval=0, argrepr='',
offset=26, starts_line=None, is_jump_target=False),
Instruction(opname='BUILD_MAP', opcode=105, arg=0, argval=0, argrepr='',
offset=28, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=7, argval='Hello world!',
argrepr="'Hello world!'", offset=30, starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=6, argval='Hello world!',
argrepr="'Hello world!'", offset=30, starts_line=None, is_jump_target=False),
Instruction(opname='CALL_FUNCTION', opcode=131, arg=7, argval=7, argrepr='',
offset=32, starts_line=None, is_jump_target=False),
Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='',
offset=34, starts_line=None, is_jump_target=False),
Instruction(opname='LOAD_FAST', opcode=124, arg=2, argval='f', argrepr='f',
offset=36, starts_line=8, is_jump_target=False),
@@ -736,14 +736,14 @@
]
expected_opinfo_f = [
- Instruction(opname='LOAD_CONST', opcode=100, arg=5, argval=(5, 6),
argrepr='(5, 6)', offset=0, starts_line=3, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=1, argval=(5, 6),
argrepr='(5, 6)', offset=0, starts_line=3, is_jump_target=False),
Instruction(opname='LOAD_CLOSURE', opcode=135, arg=2, argval='a',
argrepr='a', offset=2, starts_line=None, is_jump_target=False),
Instruction(opname='LOAD_CLOSURE', opcode=135, arg=3, argval='b',
argrepr='b', offset=4, starts_line=None, is_jump_target=False),
Instruction(opname='LOAD_CLOSURE', opcode=135, arg=0, argval='c',
argrepr='c', offset=6, starts_line=None, is_jump_target=False),
Instruction(opname='LOAD_CLOSURE', opcode=135, arg=1, argval='d',
argrepr='d', offset=8, starts_line=None, is_jump_target=False),
Instruction(opname='BUILD_TUPLE', opcode=102, arg=4, argval=4, argrepr='',
offset=10, starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=3,
argval=code_object_inner, argrepr=repr(code_object_inner), offset=12,
starts_line=None, is_jump_target=False),
- Instruction(opname='LOAD_CONST', opcode=100, arg=4,
argval='outer.<locals>.f.<locals>.inner',
argrepr="'outer.<locals>.f.<locals>.inner'", offset=14, starts_line=None,
is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=2,
argval=code_object_inner, argrepr=repr(code_object_inner), offset=12,
starts_line=None, is_jump_target=False),
+ Instruction(opname='LOAD_CONST', opcode=100, arg=3,
argval='outer.<locals>.f.<locals>.inner',
argrepr="'outer.<locals>.f.<locals>.inner'", offset=14, starts_line=None,
is_jump_target=False),
Instruction(opname='MAKE_FUNCTION', opcode=132, arg=9, argval=9, argrepr='',
offset=16, starts_line=None, is_jump_target=False),
Instruction(opname='STORE_FAST', opcode=125, arg=2, argval='inner',
argrepr='inner', offset=18, starts_line=None, is_jump_target=False),
Instruction(opname='LOAD_GLOBAL', opcode=116, arg=0, argval='print',
argrepr='print', offset=20, starts_line=5, is_jump_target=False),
diff --git a/lib-python/3/test/test_extcall.py
b/lib-python/3/test/test_extcall.py
--- a/lib-python/3/test/test_extcall.py
+++ b/lib-python/3/test/test_extcall.py
@@ -57,7 +57,7 @@
Traceback (most recent call last):
...
TypeError: ...got multiple values for keyword argument 'a'
- >>> f(1, 2, a=3, **{'a': 4}, **{'a': 5})
+ >>> f(1, 2, a=3, **{'a': 4}, **{'a': 5}) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
TypeError: ...got multiple values for keyword argument 'a'
@@ -254,20 +254,21 @@
...
TypeError: h() argument after * must be an iterable, not function
- >>> h(*[1], *h)
+ >>> h(*[1], *h) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
- TypeError: h() argument after * must be an iterable, not function
+ TypeError: ...
>>> dir(*h)
Traceback (most recent call last):
...
TypeError: dir() argument after * must be an iterable, not function
- >>> None(*h)
+ >>> None(**h) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
- TypeError: ...argument after * must be an iterable, not function
+ TypeError: ... object argument after ** must be a mapping, \
+not function
>>> h(**h)
Traceback (most recent call last):
@@ -289,35 +290,20 @@
...
TypeError: h() argument after ** must be a mapping, not list
- >>> h(**{'a': 1}, **h)
+ >>> h(**{'a': 1}, **h) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
- TypeError: h() argument after ** must be a mapping, not function
+ TypeError: ...argument after ** must be a mapping, not function
- >>> h(**{'a': 1}, **[])
+ >>> h(**{'a': 1}, **[]) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
- TypeError: h() argument after ** must be a mapping, not list
+ TypeError: ...argument after ** must be a mapping, not list
>>> dir(**h)
Traceback (most recent call last):
...
- TypeError: ...argument after * must be an iterable, not function
-
- >>> None(*h) #doctest: +ELLIPSIS
- Traceback (most recent call last):
- ...
- TypeError: ...argument after * must be an iterable, not function
-
- >>> h(**h) #doctest: +ELLIPSIS
- Traceback (most recent call last):
- ...
- TypeError: ...argument after ** must be a mapping, not function
-
- >>> dir(**h) #doctest: +ELLIPSIS
- Traceback (most recent call last):
- ...
- TypeError: ...argument after ** must be a mapping, not function
+ TypeError: dir() argument after ** must be a mapping, not function
>>> None(**h) #doctest: +ELLIPSIS
Traceback (most recent call last):
diff --git a/lib-python/3/test/test_flufl.py b/lib-python/3/test/test_flufl.py
--- a/lib-python/3/test/test_flufl.py
+++ b/lib-python/3/test/test_flufl.py
@@ -15,7 +15,7 @@
self.assertEqual(cm.exception.text, '2 != 3\n')
self.assertEqual(cm.exception.filename, '<FLUFL test>')
self.assertEqual(cm.exception.lineno, 2)
- self.assertEqual(cm.exception.offset, 4)
+ self.assertEqual(cm.exception.offset, 2) # changed in PyPy
def test_guido_as_bdfl(self):
code = '2 {0} 3'
@@ -26,7 +26,7 @@
self.assertEqual(cm.exception.text, '2 <> 3\n')
self.assertEqual(cm.exception.filename, '<FLUFL test>')
self.assertEqual(cm.exception.lineno, 1)
- self.assertEqual(cm.exception.offset, 4)
+ self.assertEqual(cm.exception.offset, 2) # changed in PyPy
if __name__ == '__main__':
diff --git a/lib_pypy/_cffi_ssl/_stdssl/__init__.py
b/lib_pypy/_cffi_ssl/_stdssl/__init__.py
--- a/lib_pypy/_cffi_ssl/_stdssl/__init__.py
+++ b/lib_pypy/_cffi_ssl/_stdssl/__init__.py
@@ -2,8 +2,18 @@
import time
import _thread
import weakref
-from _pypy_openssl import ffi
-from _pypy_openssl import lib
+
+try:
+ from _pypy_openssl import ffi
+ from _pypy_openssl import lib
+except ImportError as e:
+ import os
+ msg = "\n\nThe _ssl cffi module either doesn't exist or is incompatible
with your machine's shared libraries.\n" + \
+ "If you have a compiler installed, you can try to rebuild it by
running:\n" + \
+ "cd %s\n" %
os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + \
+ "%s _ssl_build.py\n" % sys.executable
+ raise ImportError(str(e) + msg)
+
from _cffi_ssl._stdssl.certificate import (_test_decode_cert,
_decode_certificate, _certificate_to_der)
from _cffi_ssl._stdssl.utility import (_str_with_len, _bytes_with_len,
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
@@ -275,6 +275,8 @@
raise TypeError("Can't multiply a ctypes type by a non-integer")
if length < 0:
raise ValueError("Array length must be >= 0")
+ if length * base._sizeofinstances() > sys.maxsize:
+ raise OverflowError("array too large")
key = (base, length)
try:
return ARRAY_CACHE[key]
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
@@ -1,31 +1,42 @@
+from cffi import FFI, VerificationError
import os
-from cffi import FFI, VerificationError
+version_str = '''
+ static const int NCURSES_VERSION_MAJOR;
+ static const int NCURSES_VERSION_MINOR;
+'''
-def find_curses_library():
- for curses_library in ['ncursesw', 'ncurses']:
+version = (0, 0)
+def find_library(options):
+ global version
+ for library in options:
ffi = FFI()
- ffi.set_source("_curses_cffi_check", "", libraries=[curses_library])
+ ffi.cdef(version_str)
+ ffi.set_source("_curses_cffi_check", version_str, libraries=[library])
try:
ffi.compile()
+ import _curses_cffi_check
+ lib = _curses_cffi_check.lib
+ version = (lib.NCURSES_VERSION_MAJOR, lib.NCURSES_VERSION_MINOR)
except VerificationError as e:
e_last = e
continue
else:
- return curses_library
+ return library
- # If none of the libraries is available, present the user a meaningful
+ # If none of the options is available, present the user a meaningful
# error message
raise e_last
def find_curses_include_dirs():
+ if os.path.exists('/usr/include/ncurses'):
+ return ['/usr/include/ncurses']
if os.path.exists('/usr/include/ncursesw'):
return ['/usr/include/ncursesw']
return []
ffi = FFI()
-
ffi.set_source("_curses_cffi", """
#ifdef __APPLE__
/* the following define is necessary for OS X 10.6+; without it, the
@@ -72,7 +83,8 @@
void _m_getsyx(int *yx) {
getsyx(yx[0], yx[1]);
}
-""", libraries=[find_curses_library(), 'panel'],
+""", libraries=[find_library(['ncurses', 'ncursesw']),
+ find_library(['panel', 'panelw'])],
include_dirs=find_curses_include_dirs())
@@ -84,8 +96,6 @@
typedef unsigned long... chtype;
typedef chtype attr_t;
-typedef int... wint_t;
-
typedef struct
{
short id; /* ID to distinguish multiple devices */
@@ -157,11 +167,11 @@
int setupterm(char *, int, int *);
-WINDOW *stdscr;
-int COLORS;
-int COLOR_PAIRS;
-int COLS;
-int LINES;
+extern WINDOW *stdscr;
+extern int COLORS;
+extern int COLOR_PAIRS;
+extern int COLS;
+extern int LINES;
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit