Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch: expose-jsonmap
Changeset: r97927:bae753faf6ac
Date: 2019-11-01 22:01 +0100
http://bitbucket.org/pypy/pypy/changeset/bae753faf6ac/
Log: merge default
diff too long, truncating to 2000 out of 7524 lines
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
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
@@ -287,7 +287,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 +306,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 +818,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 +836,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 +849,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 +881,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 +905,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 +923,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 +1075,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 +1084,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 +1454,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 +1463,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 +1654,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 +1680,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 +1813,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 +1947,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 +2148,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 +2162,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
@@ -84,7 +84,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 +159,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 +183,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 +284,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 +406,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 +561,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 +814,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 +969,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 +1014,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 +1058,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 +1071,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 +1082,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 +1205,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 +1221,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 +1336,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 +1626,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 +1787,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 +1856,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 +1867,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];
""")
@@ -2090,7 +2090,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
@@ -268,7 +268,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 +287,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 +791,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 +809,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 +821,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 +853,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 +878,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 +896,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 +1039,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 +1048,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 +1424,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 +1433,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 +1618,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 +1644,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 +1658,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 +1779,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 +1913,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 +2112,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 +2253,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/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
@@ -86,7 +86,7 @@
arch = platform.machine()
g['LDSHARED'] += ' -undefined dynamic_lookup'
g['CC'] += ' -arch %s' % (arch,)
- g['MACOSX_DEPLOYMENT_TARGET'] = '10.14'
+ g['MACOSX_DEPLOYMENT_TARGET'] = '10.7'
global _config_vars
_config_vars = g
diff --git a/lib-python/2.7/ensurepip/__init__.py
b/lib-python/2.7/ensurepip/__init__.py
--- a/lib-python/2.7/ensurepip/__init__.py
+++ b/lib-python/2.7/ensurepip/__init__.py
@@ -12,9 +12,9 @@
__all__ = ["version", "bootstrap"]
-_SETUPTOOLS_VERSION = "28.8.0"
+_SETUPTOOLS_VERSION = "41.2.0"
-_PIP_VERSION = "9.0.1"
+_PIP_VERSION = "19.2.3"
_PROJECTS = [
("setuptools", _SETUPTOOLS_VERSION),
@@ -28,8 +28,8 @@
sys.path = additional_paths + sys.path
# Install the bundled software
- import pip
- pip.main(args)
+ import pip._internal
+ return pip._internal.main(args)
def version():
diff --git a/lib-python/2.7/ensurepip/_bundled/pip-19.2.3-py2.py3-none-any.whl
b/lib-python/2.7/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/2.7/ensurepip/_bundled/pip-9.0.1-py2.py3-none-any.whl
b/lib-python/2.7/ensurepip/_bundled/pip-9.0.1-py2.py3-none-any.whl
deleted file mode 100644
index
4b8ecc69db7e37fc6dd7b6dd8f690508f42866a1..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
[cut]
diff --git
a/lib-python/2.7/ensurepip/_bundled/setuptools-28.8.0-py2.py3-none-any.whl
b/lib-python/2.7/ensurepip/_bundled/setuptools-28.8.0-py2.py3-none-any.whl
deleted file mode 100644
index
502e3cb418c154872ad6e677ef8b63557b38ec35..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
[cut]
diff --git
a/lib-python/2.7/ensurepip/_bundled/setuptools-41.2.0-py2.py3-none-any.whl
b/lib-python/2.7/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_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 as _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(__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/_curses_build.py b/lib_pypy/_curses_build.py
--- a/lib_pypy/_curses_build.py
+++ b/lib_pypy/_curses_build.py
@@ -1,14 +1,28 @@
from cffi import FFI
import os
-# On some systems, the ncurses library is
-# located at /usr/include/ncurses, so we must check this case.
-# Let's iterate over well known paths
-incdirs = []
-for _path in ['/usr/include', '/usr/include/ncurses']:
- if os.path.isfile(os.path.join(_path, 'panel.h')):
- incdirs.append(_path)
- break
+def find_library(options):
+ for library in options:
+ ffi = FFI()
+ ffi.set_source("_curses_cffi_check", "", libraries=[library])
+ try:
+ ffi.compile()
+ except VerificationError as e:
+ e_last = e
+ continue
+ else:
+ return library
+
+ # 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()
@@ -59,8 +73,9 @@
void _m_getsyx(int *yx) {
getsyx(yx[0], yx[1]);
}
-""", include_dirs=incdirs,
- libraries=['ncurses', 'panel'])
+""", libraries=[find_library(['ncurses', 'ncursesw']),
+ find_library(['panel', 'panelw'])],
+ include_dirs=find_curses_include_dirs())
ffi.cdef("""
@@ -71,6 +86,8 @@
typedef unsigned long... chtype;
typedef chtype attr_t;
+typedef int... wint_t;
+
typedef struct
{
short id; /* ID to distinguish multiple devices */
@@ -82,6 +99,7 @@
static const int ERR, OK;
static const int TRUE, FALSE;
static const int KEY_MIN, KEY_MAX;
+static const int KEY_CODE_YES;
static const int COLOR_BLACK;
static const int COLOR_RED;
@@ -168,6 +186,8 @@
void filter(void);
int flash(void);
int flushinp(void);
+int wget_wch(WINDOW *, wint_t *);
+int mvwget_wch(WINDOW *, int, int, wint_t *);
chtype getbkgd(WINDOW *);
WINDOW * getwin(FILE *);
int halfdelay(int);
@@ -243,6 +263,7 @@
int touchwin(WINDOW *);
int typeahead(int);
int ungetch(int);
+int unget_wch(const wchar_t);
int untouchwin(WINDOW *);
void use_env(bool);
int waddch(WINDOW *, const chtype);
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.13.0
+Version: 1.13.1
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
@@ -5,8 +5,8 @@
from .error import CDefError, FFIError, VerificationError, VerificationMissing
from .error import PkgConfigError
-__version__ = "1.13.0"
-__version_info__ = (1, 13, 0)
+__version__ = "1.13.1"
+__version_info__ = (1, 13, 1)
# 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/_embedding.h b/lib_pypy/cffi/_embedding.h
--- a/lib_pypy/cffi/_embedding.h
+++ b/lib_pypy/cffi/_embedding.h
@@ -224,7 +224,7 @@
if (f != NULL && f != Py_None) {
PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME
- "\ncompiled with cffi version: 1.13.0"
+ "\ncompiled with cffi version: 1.13.1"
"\n_cffi_backend module: ", f);
modules = PyImport_GetModuleDict();
mod = PyDict_GetItemString(modules, "_cffi_backend");
@@ -327,13 +327,15 @@
#endif
/* call Py_InitializeEx() */
- {
- PyGILState_STATE state = PyGILState_UNLOCKED;
- if (!Py_IsInitialized())
- _cffi_py_initialize();
- else
- state = PyGILState_Ensure();
-
+ if (!Py_IsInitialized()) {
+ _cffi_py_initialize();
+ PyEval_InitThreads();
+ PyEval_SaveThread(); /* release the GIL */
+ /* the returned tstate must be the one that has been stored into the
+ autoTLSkey by _PyGILState_Init() called from Py_Initialize(). */
+ }
+ else {
+ PyGILState_STATE state = PyGILState_Ensure();
PyEval_InitThreads();
PyGILState_Release(state);
}
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
@@ -156,6 +156,13 @@
"confuse pre-parsing.")
break
+def _warn_for_non_extern_non_static_global_variable(decl):
+ if not decl.storage:
+ import warnings
+ warnings.warn("Declaration of global variable '%s' in cdef() should "
+ "be marked 'extern' for consistency (or possibly "
+ "'static' in API mode)" % (decl.name,))
+
def _preprocess(csource):
# Remove comments. NOTE: this only work because the cdef() section
# should not contain any string literal!
@@ -506,6 +513,7 @@
if (quals & model.Q_CONST) and not tp.is_array_type:
self._declare('constant ' + decl.name, tp, quals=quals)
else:
+ _warn_for_non_extern_non_static_global_variable(decl)
self._declare('variable ' + decl.name, tp, quals=quals)
def parse_type(self, cdecl):
diff --git a/lib_pypy/pyrepl/historical_reader.py
b/lib_pypy/pyrepl/historical_reader.py
--- a/lib_pypy/pyrepl/historical_reader.py
+++ b/lib_pypy/pyrepl/historical_reader.py
@@ -111,7 +111,7 @@
r.isearch_term = ''
r.dirty = 1
r.push_input_trans(r.isearch_trans)
-
+
class reverse_history_isearch(commands.Command):
def do(self):
@@ -217,7 +217,7 @@
self.isearch_trans = input.KeymapTranslator(
isearch_keymap, invalid_cls=isearch_end,
character_cls=isearch_add_character)
-
+
def select_item(self, i):
self.transient_history[self.historyi] = self.get_unicode()
buf = self.transient_history.get(i)
@@ -302,7 +302,7 @@
reader.ps1 = "h**> "
reader.ps2 = "h/*> "
reader.ps3 = "h|*> "
- reader.ps4 = "h\*> "
+ reader.ps4 = r"h\*> "
while reader.readline():
pass
diff --git a/lib_pypy/pyrepl/keymap.py b/lib_pypy/pyrepl/keymap.py
--- a/lib_pypy/pyrepl/keymap.py
+++ b/lib_pypy/pyrepl/keymap.py
@@ -58,7 +58,7 @@
"'":"'",
'"':'"',
'a':'\a',
- 'b':'\h',
+ 'b':'\b',
'e':'\033',
'f':'\f',
'n':'\n',
diff --git a/lib_pypy/pyrepl/reader.py b/lib_pypy/pyrepl/reader.py
--- a/lib_pypy/pyrepl/reader.py
+++ b/lib_pypy/pyrepl/reader.py
@@ -232,7 +232,7 @@
self.ps1 = "->> "
self.ps2 = "/>> "
self.ps3 = "|.. "
- self.ps4 = "\__ "
+ self.ps4 = r"\__ "
self.kill_ring = []
self.arg = None
self.finished = 0
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -37,7 +37,7 @@
"binascii", "_multiprocessing", '_warnings', "_collections",
"_multibytecodec", "micronumpy", "_continuation", "_cffi_backend",
"_csv", "_cppyy", "_pypyjson", "_jitlog",
- #" _ssl", "_hashlib", "crypt"
+ # "_hashlib", "crypt"
])
import rpython.rlib.rvmprof.cintf
diff --git a/pypy/doc/index-of-whatsnew.rst b/pypy/doc/index-of-whatsnew.rst
--- a/pypy/doc/index-of-whatsnew.rst
+++ b/pypy/doc/index-of-whatsnew.rst
@@ -43,6 +43,7 @@
.. toctree::
whatsnew-pypy3-head.rst
+ whatsnew-pypy3-7.2.0.rst
whatsnew-pypy3-7.1.0.rst
CPython 3.5 compatible versions
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
@@ -9,3 +9,14 @@
Fix segfault when calling descr-methods with no arguments
+.. branch: https-readme
+
+Convert http -> https in README.rst
+
+.. branch: license-update
+
+Update list directories in LICENSE
+
+.. branch: allow-forcing-no-embed
+
+When packaging, allow suppressing embedded dependencies via
PYPY_NO_EMBED_DEPENDENCIES
diff --git a/pypy/doc/whatsnew-pypy3-5.10.0.rst
b/pypy/doc/whatsnew-pypy3-5.10.0.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/whatsnew-pypy3-5.10.0.rst
@@ -0,0 +1,7 @@
+========================
+What's new in PyPy3 7.0+
+========================
+
+.. this is the revision after release-pypy3.5-v7.0
+.. startrev: 9d2fa7c63b7c
+
diff --git a/pypy/doc/whatsnew-pypy3-6.0.0.rst
b/pypy/doc/whatsnew-pypy3-6.0.0.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/whatsnew-pypy3-6.0.0.rst
@@ -0,0 +1,7 @@
+========================
+What's new in PyPy3 7.0+
+========================
+
+.. this is the revision after release-pypy3.5-v7.0
+.. startrev: 9d2fa7c63b7c
+
diff --git a/pypy/doc/whatsnew-pypy3-7.1.0.rst
b/pypy/doc/whatsnew-pypy3-7.1.0.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/whatsnew-pypy3-7.1.0.rst
@@ -0,0 +1,11 @@
+========================
+What's new in PyPy3 7.0+
+========================
+
+.. this is the revision after release-pypy3.6-v7.0
+.. startrev: 33fe3b2cf186
+
+.. branch: py3.5
+
+Merge in py.35 and use this branch as the primary pypy3 one
+
diff --git a/pypy/doc/whatsnew-pypy3-7.2.0.rst
b/pypy/doc/whatsnew-pypy3-7.2.0.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/whatsnew-pypy3-7.2.0.rst
@@ -0,0 +1,58 @@
+=========================
+What's new in PyPy3 7.2.0
+=========================
+
+.. this is the revision after release-pypy3.6-v7.1.1
+.. startrev: db5a1e7fbbd0
+
+.. branch: fix-literal-prev_digit-underscore
+
+Fix parsing for converting strings with underscore into ints
+
+.. branch: winmultiprocessing
+
+Improve multiprocessing support on win32
+
+.. branch: setitem2d
+
+Allow 2d indexing in ``memoryview.__setitem__`` (issue bb-3028)
+
+.. branch: py3.6-socket-fix
+.. branch: fix-importerror
+.. branch: dj_s390
+.. branch: bpo-35409
+.. branch: remove_array_with_char_test
+.. branch: fix_test_unicode_outofrange
+.. branch: Ram-Rachum/faulthandleris_enabled-should-return-fal-1563636614875
+.. branch:
Anthony-Sottile/fix-leak-of-file-descriptor-with-_iofile-1559687440863
+
+.. branch: py3tests
+
+Add handling of application-level test files and -D flag to test runner
+
+.. branch: vendor/stdlib-3.6
+.. branch: stdlib-3.6.9
+
+Update standard library to version 3.6.9
+
+.. branch: __debug__-optimize
+
+Fix handling of __debug__, sys.flags.optimize, and '-O' command-line flag to
+match CPython 3.6.
+
+.. branch: more-cpyext
+
+Add ``PyErr_SetFromWindowsErr`` and ``pytime.h``, ``pytime.c``. Fix order of
+fields in ``Py_buffer``.
+
+.. branch: Ryan-Hileman/add-support-for-zipfile-stdlib-1562420744699
+
+Add support for the entire stdlib being inside a zipfile
+
+
+.. branch: json-decoder-maps-py3.6
+
+Much faster and more memory-efficient JSON decoding. The resulting
+dictionaries that come out of the JSON decoder have faster lookups too.
+
+
diff --git a/pypy/doc/whatsnew-pypy3-head.rst b/pypy/doc/whatsnew-pypy3-head.rst
--- a/pypy/doc/whatsnew-pypy3-head.rst
+++ b/pypy/doc/whatsnew-pypy3-head.rst
@@ -1,7 +1,7 @@
-========================
-What's new in PyPy3 7.0+
-========================
-
-.. this is the revision after release-pypy3.5-v7.0
-.. startrev: 9d2fa7c63b7c
-
+========================
+What's new in PyPy3 7.2+
+========================
+
+.. this is the revision after release-pypy3.6-v7.2
+.. startrev: 6d2f8470165b
+
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -22,9 +22,13 @@
__all__ = ['ObjSpace', 'OperationError', 'W_Root']
+def get_printable_location(tp):
+ return "unpackiterable: %s" % (tp, )
+
unpackiterable_driver = jit.JitDriver(name='unpackiterable',
greens=['tp'],
- reds=['items', 'w_iterator'])
+ reds=['items', 'w_iterator'],
+
get_printable_location=get_printable_location)
class W_Root(object):
diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -310,6 +310,9 @@
return space.w_None
return tb
+ def got_any_traceback(self):
+ return self._application_traceback is not None
+
def set_traceback(self, traceback):
"""Set the current traceback."""
self._application_traceback = traceback
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -832,8 +832,20 @@
w_metaclass = find_metaclass(self.space, w_bases,
w_methodsdict, self.get_w_globals(),
self.get_builtin())
- w_newclass = self.space.call_function(w_metaclass, w_name,
- w_bases, w_methodsdict)
+ try:
+ w_newclass = self.space.call_function(w_metaclass, w_name,
+ w_bases, w_methodsdict)
+ except OperationError as e:
+ # give a more comprehensible error message for TypeErrors
+ if e.got_any_traceback():
+ raise
+ if not e.match(self.space, self.space.w_TypeError):
+ raise
+ raise oefmt(self.space.w_TypeError,
+ "metaclass found to be '%N', but calling %R "
+ "with args (%R, %R, dict) raised %R",
+ w_metaclass, w_metaclass, w_name, w_bases,
+ e.get_w_value(self.space))
self.pushvalue(w_newclass)
def STORE_NAME(self, varindex, next_instr):
diff --git a/pypy/interpreter/test/apptest_function.py
b/pypy/interpreter/test/apptest_function.py
new file mode 100644
--- /dev/null
+++ b/pypy/interpreter/test/apptest_function.py
@@ -0,0 +1,615 @@
+from pytest import raises, skip
+
+def test_attributes():
+ globals()['__name__'] = 'mymodulename'
+ def f(): pass
+ assert hasattr(f, 'func_code')
+ assert f.func_defaults == None
+ f.func_defaults = None
+ assert f.func_defaults == None
+ assert f.func_dict == {}
+ assert type(f.func_globals) == dict
+ assert f.func_globals is f.__globals__
+ assert f.func_closure is None
+ assert f.func_doc == None
+ assert f.func_name == 'f'
+ assert f.__module__ == 'mymodulename'
+
+def test_code_is_ok():
+ def f(): pass
+ assert not hasattr(f.func_code, '__dict__')
+
+def test_underunder_attributes():
+ def f(): pass
+ assert f.__name__ == 'f'
+ assert f.__doc__ == None
+ assert f.__name__ == f.func_name
+ assert f.__doc__ == f.func_doc
+ assert f.__dict__ is f.func_dict
+ assert f.__code__ is f.func_code
+ assert f.__defaults__ is f.func_defaults
+ assert hasattr(f, '__class__')
+
+def test_classmethod():
+ def f():
+ pass
+ assert classmethod(f).__func__ is f
+ assert staticmethod(f).__func__ is f
+
+def test_write_doc():
+ def f(): "hello"
+ assert f.__doc__ == 'hello'
+ f.__doc__ = 'good bye'
+ assert f.__doc__ == 'good bye'
+ del f.__doc__
+ assert f.__doc__ == None
+
+def test_write_func_doc():
+ def f(): "hello"
+ assert f.func_doc == 'hello'
+ f.func_doc = 'good bye'
+ assert f.func_doc == 'good bye'
+ del f.func_doc
+ assert f.func_doc == None
+
+def test_write_module():
+ def f(): "hello"
+ f.__module__ = 'ab.c'
+ assert f.__module__ == 'ab.c'
+ del f.__module__
+ assert f.__module__ is None
+
+def test_new():
+ def f(): return 42
+ FuncType = type(f)
+ f2 = FuncType(f.func_code, f.func_globals, 'f2', None, None)
+ assert f2() == 42
+
+ def g(x):
+ def f():
+ return x
+ return f
+ f = g(42)
+ with raises(TypeError):
+ FuncType(f.func_code, f.func_globals, 'f2', None, None)
+
+def test_write_code():
+ def f():
+ return 42
+ def g():
+ return 41
+ assert f() == 42
+ assert g() == 41
+ with raises(TypeError):
+ f.func_code = 1
+ f.func_code = g.func_code
+ assert f() == 41
+ def h():
+ return f() # a closure
+ with raises(ValueError):
+ f.func_code = h.func_code
+
+def test_write_code_builtin_forbidden():
+ def f(*args):
+ return 42
+ with raises(TypeError):
+ dir.func_code = f.func_code
+ with raises(TypeError):
+ list.append.im_func.func_code = f.func_code
+
+def test_set_name():
+ def f(): pass
+ f.__name__ = 'g'
+ assert f.func_name == 'g'
+ with raises(TypeError):
+ f.__name__ = u'g'
+
+
+def test_simple_call():
+ def func(arg1, arg2):
+ return arg1, arg2
+ res = func(23,42)
+ assert res[0] == 23
+ assert res[1] == 42
+
+def test_simple_call_default():
+ def func(arg1, arg2=11, arg3=111):
+ return arg1, arg2, arg3
+ res = func(1)
+ assert res[0] == 1
+ assert res[1] == 11
+ assert res[2] == 111
+ res = func(1, 22)
+ assert res[0] == 1
+ assert res[1] == 22
+ assert res[2] == 111
+ res = func(1, 22, 333)
+ assert res[0] == 1
+ assert res[1] == 22
+ assert res[2] == 333
+
+ with raises(TypeError):
+ func()
+ with raises(TypeError):
+ func(1, 2, 3, 4)
+
+def test_simple_varargs():
+ def func(arg1, *args):
+ return arg1, args
+ res = func(23,42)
+ assert res[0] == 23
+ assert res[1] == (42,)
+
+ res = func(23, *(42,))
+ assert res[0] == 23
+ assert res[1] == (42,)
+
+def test_simple_kwargs():
+ def func(arg1, **kwargs):
+ return arg1, kwargs
+ res = func(23, value=42)
+ assert res[0] == 23
+ assert res[1] == {'value': 42}
+
+ res = func(23, **{'value': 42})
+ assert res[0] == 23
+ assert res[1] == {'value': 42}
+
+def test_kwargs_sets_wrong_positional_raises():
+ def func(arg1):
+ pass
+ with raises(TypeError):
+ func(arg2=23)
+
+def test_kwargs_sets_positional():
+ def func(arg1):
+ return arg1
+ res = func(arg1=42)
+ assert res == 42
+
+def test_kwargs_sets_positional_mixed():
+ def func(arg1, **kw):
+ return arg1, kw
+ res = func(arg1=42, something=23)
+ assert res[0] == 42
+ assert res[1] == {'something': 23}
+
+def test_kwargs_sets_positional_twice():
+ def func(arg1, **kw):
+ return arg1, kw
+ with raises(TypeError):
+ func(42, {'arg1': 23})
+
+def test_kwargs_nondict_mapping():
+ class Mapping:
+ def keys(self):
+ return ('a', 'b')
+ def __getitem__(self, key):
+ return key
+ def func(arg1, **kw):
+ return arg1, kw
+ res = func(23, **Mapping())
+ assert res[0] == 23
+ assert res[1] == {'a': 'a', 'b': 'b'}
+ with raises(TypeError) as excinfo:
+ func(42, **[])
+ assert excinfo.value.message == (
+ 'argument after ** must be a mapping, not list')
+
+def test_default_arg():
+ def func(arg1,arg2=42):
+ return arg1, arg2
+ res = func(arg1=23)
+ assert res[0] == 23
+ assert res[1] == 42
+
+def test_defaults_keyword_overrides():
+ def func(arg1=42, arg2=23):
+ return arg1, arg2
+ res = func(arg1=23)
+ assert res[0] == 23
+ assert res[1] == 23
+
+def test_defaults_keyword_override_but_leaves_empty_positional():
+ def func(arg1,arg2=42):
+ return arg1, arg2
+ with raises(TypeError):
+ func(arg2=23)
+
+def test_kwargs_disallows_same_name_twice():
+ def func(arg1, **kw):
+ return arg1, kw
+ with raises(TypeError):
+ func(42, **{'arg1': 23})
+
+def test_kwargs_bound_blind():
+ class A(object):
+ def func(self, **kw):
+ return self, kw
+ func = A().func
+ with raises(TypeError):
+ func(self=23)
+ with raises(TypeError):
+ func(**{'self': 23})
+
+def test_kwargs_confusing_name():
+ def func(self): # 'self' conflicts with the interp-level
+ return self*7 # argument to call_function()
+ res = func(self=6)
+ assert res == 42
+
+def test_get():
+ def func(self): return self
+ obj = object()
+ meth = func.__get__(obj, object)
+ assert meth() == obj
+
+def test_none_get_interaction():
+ skip("XXX issue #2083")
+ assert type(None).__repr__(None) == 'None'
+
+def test_none_get_interaction_2():
+ f = None.__repr__
+ assert f() == 'None'
+
+def test_no_get_builtin():
+ assert not hasattr(dir, '__get__')
+ class A(object):
+ ord = ord
+ a = A()
+ assert a.ord('a') == 97
+
+def test_builtin_as_special_method_is_not_bound():
+ class A(object):
+ __getattr__ = len
+ a = A()
+ assert a.a == 1
+ assert a.ab == 2
+ assert a.abcdefghij == 10
+
+def test_call_builtin():
+ s = 'hello'
+ with raises(TypeError):
+ len()
+ assert len(s) == 5
+ with raises(TypeError):
+ len(s, s)
+ with raises(TypeError):
+ len(s, s, s)
+ assert len(*[s]) == 5
+ assert len(s, *[]) == 5
+ with raises(TypeError):
+ len(some_unknown_keyword=s)
+ with raises(TypeError):
+ len(s, some_unknown_keyword=s)
+ with raises(TypeError):
+ len(s, s, some_unknown_keyword=s)
+
+def test_call_error_message():
+ try:
+ len()
+ except TypeError as e:
+ assert "len() takes exactly 1 argument (0 given)" in e.message
+ else:
+ assert 0, "did not raise"
+
+ try:
+ len(1, 2)
+ except TypeError as e:
+ assert "len() takes exactly 1 argument (2 given)" in e.message
+ else:
+ assert 0, "did not raise"
+
+def test_unicode_docstring():
+ def f():
+ u"hi"
+ assert f.__doc__ == u"hi"
+ assert type(f.__doc__) is unicode
+
+def test_issue1293():
+ def f1(): "doc f1"
+ def f2(): "doc f2"
+ f1.func_code = f2.func_code
+ assert f1.__doc__ == "doc f1"
+
+def test_subclassing():
+ # cannot subclass 'function' or 'builtin_function'
+ def f():
+ pass
+ with raises(TypeError):
+ type('Foo', (type(f),), {})
+ with raises(TypeError):
+ type('Foo', (type(len),), {})
+
+def test_lambda_docstring():
+ # Like CPython, (lambda:"foo") has a docstring of "foo".
+ # But let's not test that. Just test that (lambda:42) does not
+ # have 42 as docstring.
+ f = lambda: 42
+ assert f.func_doc is None
+
+def test_setstate_called_with_wrong_args():
+ f = lambda: 42
+ # not sure what it should raise, since CPython doesn't have setstate
+ # on function types
+ with raises(ValueError):
+ type(f).__setstate__(f, (1, 2, 3))
+
+def test_simple_call():
+ class A(object):
+ def func(self, arg2):
+ return self, arg2
+ a = A()
+ res = a.func(42)
+ assert res[0] is a
+ assert res[1] == 42
+
+def test_simple_varargs():
+ class A(object):
+ def func(self, *args):
+ return self, args
+ a = A()
+ res = a.func(42)
+ assert res[0] is a
+ assert res[1] == (42,)
+
+ res = a.func(*(42,))
+ assert res[0] is a
+ assert res[1] == (42,)
+
+def test_obscure_varargs():
+ class A(object):
+ def func(*args):
+ return args
+ a = A()
+ res = a.func(42)
+ assert res[0] is a
+ assert res[1] == 42
+
+ res = a.func(*(42,))
+ assert res[0] is a
+ assert res[1] == 42
+
+def test_simple_kwargs():
+ class A(object):
+ def func(self, **kwargs):
+ return self, kwargs
+ a = A()
+
+ res = a.func(value=42)
+ assert res[0] is a
+ assert res[1] == {'value': 42}
+
+ res = a.func(**{'value': 42})
+ assert res[0] is a
+ assert res[1] == {'value': 42}
+
+def test_get():
+ def func(self): return self
+ class Object(object): pass
+ obj = Object()
+ # Create bound method from function
+ obj.meth = func.__get__(obj, Object)
+ assert obj.meth() == obj
+ # Create bound method from method
+ meth2 = obj.meth.__get__(obj, Object)
+ assert meth2() == obj
+
+def test_get_get():
+ # sanxiyn's test from email
+ def m(self): return self
+ class C(object): pass
+ class D(C): pass
+ C.m = m
+ D.m = C.m
+ c = C()
+ assert c.m() == c
+ d = D()
+ assert d.m() == d
+
+def test_method_eq():
+ class C(object):
+ def m(): pass
+ c = C()
+ assert C.m == C.m
+ assert c.m == c.m
+ assert not (C.m == c.m)
+ assert not (c.m == C.m)
+ c2 = C()
+ assert (c.m == c2.m) is False
+ assert (c.m != c2.m) is True
+ assert (c.m != c.m) is False
+
+def test_method_hash():
+ class C(object):
+ def m(): pass
+ class D(C):
+ pass
+ c = C()
+ assert hash(C.m) == hash(D.m)
+ assert hash(c.m) == hash(c.m)
+
+def test_method_repr():
+ class A(object):
+ def f(self):
+ pass
+ assert repr(A.f) == "<unbound method A.f>"
+ assert repr(A().f).startswith("<bound method A.f of <")
+ assert repr(A().f).endswith(">>")
+ class B:
+ def f(self):
+ pass
+ assert repr(B.f) == "<unbound method B.f>"
+ assert repr(B().f).startswith("<bound method B.f of <")
+ assert repr(A().f).endswith(">>")
+
+ assert repr(type(A.f)) == repr(type(A().f)) == "<type 'instancemethod'>"
+
+
+def test_method_call():
+ class C(object):
+ def __init__(self, **kw):
+ pass
+ c = C(type='test')
+
+def test_method_w_callable():
+ class A(object):
+ def __call__(self, x):
+ return x
+ import new
+ im = new.instancemethod(A(), 3)
+ assert im() == 3
+
+def test_method_w_callable_call_function():
+ class A(object):
+ def __call__(self, x, y):
+ return x+y
+ import new
+ im = new.instancemethod(A(), 3)
+ assert map(im, [4]) == [7]
+
+def test_unbound_typecheck():
+ class A(object):
+ def foo(self, *args):
+ return args
+ class B(A):
+ pass
+ class C(A):
+ pass
+
+ assert A.foo(A(), 42) == (42,)
+ assert A.foo(B(), 42) == (42,)
+ with raises(TypeError):
+ A.foo(5)
+ with raises(TypeError):
+ B.foo(C())
+ with raises(TypeError):
+ class Fun:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit