diff options
author | 2019-11-22 12:15:13 -0800 | |
---|---|---|
committer | 2019-11-22 12:15:13 -0800 | |
commit | 01532ca91438dc08c6876d763867f27aa1ae84ef (patch) | |
tree | 676202a5d296cf23b763fe8013788dfe28d3ec1a | |
parent | more template tests from cppyy/test (CPython) (diff) | |
parent | The test for my previous commit (diff) | |
download | pypy-01532ca91438dc08c6876d763867f27aa1ae84ef.tar.gz pypy-01532ca91438dc08c6876d763867f27aa1ae84ef.tar.bz2 pypy-01532ca91438dc08c6876d763867f27aa1ae84ef.zip |
merge default into branch
38 files changed, 465 insertions, 337 deletions
diff --git a/extra_tests/cffi_tests/cffi0/test_verify.py b/extra_tests/cffi_tests/cffi0/test_verify.py index e0b7cd6c01..7d34ecf647 100644 --- a/extra_tests/cffi_tests/cffi0/test_verify.py +++ b/extra_tests/cffi_tests/cffi0/test_verify.py @@ -4,6 +4,7 @@ import pytest 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 @@ if sys.platform == 'win32': 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( diff --git a/extra_tests/cffi_tests/cffi1/test_recompiler.py b/extra_tests/cffi_tests/cffi1/test_recompiler.py index dd7b5d241f..033d26bdb7 100644 --- a/extra_tests/cffi_tests/cffi1/test_recompiler.py +++ b/extra_tests/cffi_tests/cffi1/test_recompiler.py @@ -35,8 +35,9 @@ def verify(ffi, module_name, source, *args, **kwds): 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(): @@ -2039,7 +2040,7 @@ def test_function_returns_float_complex(): 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 diff --git a/extra_tests/cffi_tests/cffi1/test_verify1.py b/extra_tests/cffi_tests/cffi1/test_verify1.py index d71ea83c5f..de92ca6ee0 100644 --- 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 FFI, FFIError, VerificationError, VerificationMissing, model 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 @@ if sys.platform == 'win32': 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 diff --git a/extra_tests/cffi_tests/support.py b/extra_tests/cffi_tests/support.py index ee1fcbe613..b52a82cba8 100644 --- 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 @@ def _verify(ffi, module_name, preamble, *args, **kwds): 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/lib-python/2.7/sysconfig.py b/lib-python/2.7/sysconfig.py index 9621a49776..ca860cd6e3 100644 --- a/lib-python/2.7/sysconfig.py +++ b/lib-python/2.7/sysconfig.py @@ -382,6 +382,11 @@ def _init_non_posix(vars): vars['EXE'] = '.exe' vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable)) + # pypy only: give us control over the ABI tag in a wheel name + if '__pypy__' in sys.builtin_module_names: + import imp + so_ext = imp.get_suffixes()[0][0] + vars['SOABI']= '-'.join(so_ext.split('.')[1].split('-')[:2]) # # public APIs diff --git a/lib_pypy/_cffi_ssl/_stdssl/__init__.py b/lib_pypy/_cffi_ssl/_stdssl/__init__.py index 552df0d177..158ff87538 100644 --- a/lib_pypy/_cffi_ssl/_stdssl/__init__.py +++ b/lib_pypy/_cffi_ssl/_stdssl/__init__.py @@ -10,7 +10,7 @@ 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__))) + \ + "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) diff --git a/lib_pypy/_curses_build.py b/lib_pypy/_curses_build.py index 5aee20b6b5..0b3b27adbf 100644 --- a/lib_pypy/_curses_build.py +++ b/lib_pypy/_curses_build.py @@ -96,8 +96,6 @@ typedef unsigned char bool; typedef unsigned long... chtype; typedef chtype attr_t; -typedef int... wint_t; - typedef struct { short id; /* ID to distinguish multiple devices */ @@ -376,6 +374,7 @@ void _m_getsyx(int *yx); if version > (5, 7): ffi.cdef(""" +typedef int... wint_t; int wget_wch(WINDOW *, wint_t *); int mvwget_wch(WINDOW *, int, int, wint_t *); int unget_wch(const wchar_t); diff --git a/lib_pypy/cffi.egg-info/PKG-INFO b/lib_pypy/cffi.egg-info/PKG-INFO index 2b73da5530..65ec34c127 100644 --- 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.1 +Version: 1.13.2 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 index 66655e4649..ddc3614117 100644 --- a/lib_pypy/cffi/__init__.py +++ b/lib_pypy/cffi/__init__.py @@ -5,8 +5,8 @@ from .api import FFI from .error import CDefError, FFIError, VerificationError, VerificationMissing from .error import PkgConfigError -__version__ = "1.13.1" -__version_info__ = (1, 13, 1) +__version__ = "1.13.2" +__version_info__ = (1, 13, 2) # The verifier module file names are based on the CRC32 of a string that # contains the following version number. It may be older than __version__ diff --git a/lib_pypy/cffi/_cffi_include.h b/lib_pypy/cffi/_cffi_include.h index 37ea74feb4..2eeb49b3c4 100644 --- a/lib_pypy/cffi/_cffi_include.h +++ b/lib_pypy/cffi/_cffi_include.h @@ -261,12 +261,12 @@ _CFFI_UNUSED_FN static int _cffi_to_c_char32_t(PyObject *o) return (int)_cffi_to_c_wchar3216_t(o); } -_CFFI_UNUSED_FN static PyObject *_cffi_from_c_char32_t(int x) +_CFFI_UNUSED_FN static PyObject *_cffi_from_c_char32_t(unsigned int x) { if (sizeof(_cffi_wchar_t) == 4) return _cffi_from_c_wchar_t((_cffi_wchar_t)x); else - return _cffi_from_c_wchar3216_t(x); + return _cffi_from_c_wchar3216_t((int)x); } diff --git a/lib_pypy/cffi/_embedding.h b/lib_pypy/cffi/_embedding.h index 0718d24155..abd474aaf8 100644 --- a/lib_pypy/cffi/_embedding.h +++ b/lib_pypy/cffi/_embedding.h @@ -224,7 +224,7 @@ static int _cffi_initialize_python(void) if (f != NULL && f != Py_None) { PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME - "\ncompiled with cffi version: 1.13.1" + "\ncompiled with cffi version: 1.13.2" "\n_cffi_backend module: ", f); modules = PyImport_GetModuleDict(); mod = PyDict_GetItemString(modules, "_cffi_backend"); diff --git a/lib_pypy/cffi/cparser.py b/lib_pypy/cffi/cparser.py index c275f425a4..ea27c482e6 100644 --- a/lib_pypy/cffi/cparser.py +++ b/lib_pypy/cffi/cparser.py @@ -159,9 +159,9 @@ def _warn_for_string_literal(csource): 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,)) + warnings.warn("Global variable '%s' in cdef(): for consistency " + "with C it should have a storage class specifier " + "(usually 'extern')" % (decl.name,)) def _preprocess(csource): # Remove comments. NOTE: this only work because the cdef() section diff --git a/pypy/conftest.py b/pypy/conftest.py index bc4e4642b7..f42b59cb3f 100644 --- a/pypy/conftest.py +++ b/pypy/conftest.py @@ -185,7 +185,9 @@ def pytest_runtest_setup(item): from pypy.tool.pytest.objspace import gettestobjspace # Make cls.space and cls.runappdirect available in tests. spaceconfig = getattr(appclass.obj, 'spaceconfig', {}) - spaceconfig.setdefault('objspace.std.reinterpretasserts', True) + config = item.config + if not (config.getoption('runappdirect') or config.getoption('direct_apptest')): + spaceconfig.setdefault('objspace.std.reinterpretasserts', True) appclass.obj.space = gettestobjspace(**spaceconfig) appclass.obj.runappdirect = option.runappdirect diff --git a/pypy/interpreter/test/apptest_exec.py b/pypy/interpreter/test/apptest_exec.py new file mode 100644 index 0000000000..e671182d03 --- /dev/null +++ b/pypy/interpreter/test/apptest_exec.py @@ -0,0 +1,245 @@ +"""Test the exec statement functionality. + +New for PyPy - Could be incorporated into CPython regression tests. +""" +import pytest + +def test_string(): + g = {} + l = {} + exec "a = 3" in g, l + assert l['a'] == 3 + +def test_localfill(): + g = {} + exec "a = 3" in g + assert g['a'] == 3 + +def test_builtinsupply(): + g = {} + exec "pass" in g + assert g.has_key('__builtins__') + +def test_invalidglobal(): + with pytest.raises(TypeError): + exec 'pass' in 1 + +def test_invalidlocal(): + with pytest.raises(TypeError): + exec 'pass' in {}, 2 + +def test_codeobject(): + co = compile("a = 3", '<string>', 'exec') + g = {} + l = {} + exec co in g, l + assert l['a'] == 3 + +def test_implicit(): + a = 4 + exec "a = 3" + assert a == 3 + +def test_tuplelocals(): + g = {} + l = {} + exec ("a = 3", g, l) + assert l['a'] == 3 + +def test_tupleglobals(): + g = {} + exec ("a = 3", g) + assert g['a'] == 3 + +def test_exceptionfallthrough(): + with pytest.raises(TypeError): + exec 'raise TypeError' in {} + +def test_global_stmt(): + g = {} + l = {} + co = compile("global a; a=5", '', 'exec') + #import dis + #dis.dis(co) + exec co in g, l + assert l == {} + assert g['a'] == 5 + +def test_specialcase_free_load(): + exec """if 1: + def f(): + exec 'a=3' + return a + x = f()\n""" + assert x == 3 + +def test_specialcase_free_load2(): + exec """if 1: + def f(a): + exec 'a=3' + return a + x = f(4)\n""" + assert x == 3 + +def test_specialcase_globals_and_exec(): + d = {} + exec """if 1: + b = 2 + c = 3 + d = 4 + def f(a): + global b + exec 'd=42 ; b=7' + return a,b,c,d + #import dis + #dis.dis(f) + res = f(3)\n""" in d + r = d['res'] + assert r == (3,2,3,42) + +def test_nested_names_are_not_confused(): + def get_nested_class(): + method_and_var = "var" + class Test(object): + def method_and_var(self): + return "method" + def test(self): + return method_and_var + def actual_global(self): + return str("global") + def str(self): + return str(self) + return Test() + t = get_nested_class() + assert t.actual_global() == "global" + assert t.test() == 'var' + assert t.method_and_var() == 'method' + +def test_import_star_shadows_global(): + d = {'platform' : 3} + exec """if 1: + def f(): + from sys import * + return platform + res = f()\n""" in d + import sys + assert d['res'] == sys.platform + +def test_import_global_takes_precendence(): + d = {'platform' : 3} + exec """if 1: + def f(): + global platform + from sys import * + return platform + res = f()\n""" in d + import sys + assert d['platform'] == 3 + +def test_exec_load_name(): + d = {'x': 2} + exec """if 1: + def f(): + save = x + exec "x=3" + return x,save + \n""" in d + res = d['f']() + assert res == (3, 2) + +def test_space_bug(): + d = {} + exec "x=5 " in d + assert d['x'] == 5 + +def test_synerr(): + with pytest.raises(SyntaxError): + exec "1 2" + +def test_mapping_as_locals(): + import sys + if not hasattr(sys, 'pypy_objspaceclass'): + skip("need PyPy for non-dictionaries in exec statements") + class M(object): + def __getitem__(self, key): + return key + def __setitem__(self, key, value): + self.result[key] = value + def setdefault(self, key, value): + assert key == '__builtins__' + m = M() + m.result = {} + exec "x=m" in {}, m + assert m.result == {'x': 'm'} + exec "y=n" in m # NOTE: this doesn't work in CPython + assert m.result == {'x': 'm', 'y': 'n'} + +def test_filename(): + with pytest.raises(SyntaxError) as excinfo: + exec "'unmatched_quote" + assert excinfo.value.filename == '<string>' + with pytest.raises(SyntaxError) as excinfo: + eval("'unmatched_quote") + assert excinfo.value.filename == '<string>' + +def test_exec_and_name_lookups(): + ns = {} + exec """def f(): + exec 'x=1' in locals() + return x""" in ns + + f = ns['f'] + assert f() == 1 + +def test_exec_unicode(): + # 's' is a string + s = "x = u'\xd0\xb9\xd1\x86\xd1\x83\xd0\xba\xd0\xb5\xd0\xbd'" + # 'u' is a unicode + u = s.decode('utf-8') + exec u + assert len(x) == 6 + assert ord(x[0]) == 0x0439 + assert ord(x[1]) == 0x0446 + assert ord(x[2]) == 0x0443 + assert ord(x[3]) == 0x043a + assert ord(x[4]) == 0x0435 + assert ord(x[5]) == 0x043d + +def test_eval_unicode(): + u = "u'%s'" % unichr(0x1234) + v = eval(u) + assert v == unichr(0x1234) + +def test_compile_unicode(): + s = "x = u'\xd0\xb9\xd1\x86\xd1\x83\xd0\xba\xd0\xb5\xd0\xbd'" + u = s.decode('utf-8') + c = compile(u, '<input>', 'exec') + exec c + assert len(x) == 6 + assert ord(x[0]) == 0x0439 + +def test_nested_qualified_exec(): + import sys + if sys.version_info < (2, 7, 9): + skip() + code = [""" +def g(): + def f(): + if True: + exec "" in {}, {} + """, """ +def g(): + def f(): + if True: + exec("", {}, {}) + """] + for c in code: + compile(c, "<code>", "exec") + +def test_exec_tuple(): + # note: this is VERY different than testing exec("a = 42", d), because + # this specific case is handled specially by the AST compiler + d = {} + x = ("a = 42", d) + exec x + assert d['a'] == 42 diff --git a/pypy/interpreter/test/test_exec.py b/pypy/interpreter/test/test_exec.py index 62ac197acd..8f7f004105 100644 --- a/pypy/interpreter/test/test_exec.py +++ b/pypy/interpreter/test/test_exec.py @@ -16,257 +16,3 @@ def test_file(space): assert 'abc' in g assert 'cba' in g ''') - - -class AppTestExecStmt: - def test_string(self): - g = {} - l = {} - exec "a = 3" in g, l - assert l['a'] == 3 - - def test_localfill(self): - g = {} - exec "a = 3" in g - assert g['a'] == 3 - - def test_builtinsupply(self): - g = {} - exec "pass" in g - assert g.has_key('__builtins__') - - def test_invalidglobal(self): - def f(): - exec 'pass' in 1 - raises(TypeError,f) - - def test_invalidlocal(self): - def f(): - exec 'pass' in {}, 2 - raises(TypeError,f) - - def test_codeobject(self): - co = compile("a = 3", '<string>', 'exec') - g = {} - l = {} - exec co in g, l - assert l['a'] == 3 - - def test_implicit(self): - a = 4 - exec "a = 3" - assert a == 3 - - def test_tuplelocals(self): - g = {} - l = {} - exec ("a = 3", g, l) - assert l['a'] == 3 - - def test_tupleglobals(self): - g = {} - exec ("a = 3", g) - assert g['a'] == 3 - - def test_exceptionfallthrough(self): - def f(): - exec 'raise TypeError' in {} - raises(TypeError,f) - - def test_global_stmt(self): - g = {} - l = {} - co = compile("global a; a=5", '', 'exec') - #import dis - #dis.dis(co) - exec co in g, l - assert l == {} - assert g['a'] == 5 - - def test_specialcase_free_load(self): - exec """if 1: - def f(): - exec 'a=3' - return a - x = f()\n""" - assert x == 3 - - def test_specialcase_free_load2(self): - exec """if 1: - def f(a): - exec 'a=3' - return a - x = f(4)\n""" - assert x == 3 - - def test_specialcase_globals_and_exec(self): - d = {} - exec """if 1: - b = 2 - c = 3 - d = 4 - def f(a): - global b - exec 'd=42 ; b=7' - return a,b,c,d - #import dis - #dis.dis(f) - res = f(3)\n""" in d - r = d['res'] - assert r == (3,2,3,42) - - def test_nested_names_are_not_confused(self): - def get_nested_class(): - method_and_var = "var" - class Test(object): - def method_and_var(self): - return "method" - def test(self): - return method_and_var - def actual_global(self): - return str("global") - def str(self): - return str(self) - return Test() - t = get_nested_class() - assert t.actual_global() == "global" - assert t.test() == 'var' - assert t.method_and_var() == 'method' - - def test_import_star_shadows_global(self): - d = {'platform' : 3} - exec """if 1: - def f(): - from sys import * - return platform - res = f()\n""" in d - import sys - assert d['res'] == sys.platform - - def test_import_global_takes_precendence(self): - d = {'platform' : 3} - exec """if 1: - def f(): - global platform - from sys import * - return platform - res = f()\n""" in d - import sys - assert d['platform'] == 3 - - def test_exec_load_name(self): - d = {'x': 2} - exec """if 1: - def f(): - save = x - exec "x=3" - return x,save - \n""" in d - res = d['f']() - assert res == (3, 2) - - def test_space_bug(self): - d = {} - exec "x=5 " in d - assert d['x'] == 5 - - def test_synerr(self): - def x(): - exec "1 2" - raises(SyntaxError, x) - - def test_mapping_as_locals(self): - import sys - if sys.version_info < (2,5) or not hasattr(sys, 'pypy_objspaceclass'): - skip("need CPython 2.5 or PyPy for non-dictionaries in exec statements") - class M(object): - def __getitem__(self, key): - return key - def __setitem__(self, key, value): - self.result[key] = value - def setdefault(self, key, value): - assert key == '__builtins__' - m = M() - m.result = {} - exec "x=m" in {}, m - assert m.result == {'x': 'm'} - exec "y=n" in m # NOTE: this doesn't work in CPython 2.4 - assert m.result == {'x': 'm', 'y': 'n'} - - def test_filename(self): - try: - exec "'unmatched_quote" - except SyntaxError as msg: - assert msg.filename == '<string>' - try: - eval("'unmatched_quote") - except SyntaxError as msg: - assert msg.filename == '<string>' - - def test_exec_and_name_lookups(self): - ns = {} - exec """def f(): - exec 'x=1' in locals() - return x""" in ns - - f = ns['f'] - - try: - res = f() - except NameError as e: # keep py.test from exploding confused - raise e - - assert res == 1 - - def test_exec_unicode(self): - # 's' is a string - s = "x = u'\xd0\xb9\xd1\x86\xd1\x83\xd0\xba\xd0\xb5\xd0\xbd'" - # 'u' is a unicode - u = s.decode('utf-8') - exec u - assert len(x) == 6 - assert ord(x[0]) == 0x0439 - assert ord(x[1]) == 0x0446 - assert ord(x[2]) == 0x0443 - assert ord(x[3]) == 0x043a - assert ord(x[4]) == 0x0435 - assert ord(x[5]) == 0x043d - - def test_eval_unicode(self): - u = "u'%s'" % unichr(0x1234) - v = eval(u) - assert v == unichr(0x1234) - - def test_compile_unicode(self): - s = "x = u'\xd0\xb9\xd1\x86\xd1\x83\xd0\xba\xd0\xb5\xd0\xbd'" - u = s.decode('utf-8') - c = compile(u, '<input>', 'exec') - exec c - assert len(x) == 6 - assert ord(x[0]) == 0x0439 - - def test_nested_qualified_exec(self): - import sys - if sys.version_info < (2, 7, 9): - skip() - code = [""" -def g(): - def f(): - if True: - exec "" in {}, {} - """, """ -def g(): - def f(): - if True: - exec("", {}, {}) - """] - for c in code: - compile(c, "<code>", "exec") - - def test_exec_tuple(self): - # note: this is VERY different than testing exec("a = 42", d), because - # this specific case is handled specially by the AST compiler - d = {} - x = ("a = 42", d) - exec x - assert d['a'] == 42 diff --git a/pypy/module/_cffi_backend/__init__.py b/pypy/module/_cffi_backend/__init__.py index 3094cc855a..2396c00ff1 100644 --- a/pypy/module/_cffi_backend/__init__.py +++ b/pypy/module/_cffi_backend/__init__.py @@ -1 +1 @@ -VERSION = "1.13.1" +VERSION = "1.13.2" diff --git a/pypy/module/_cffi_backend/newtype.py b/pypy/module/_cffi_backend/newtype.py index bb97cc769e..44d21290b3 100644 --- a/pypy/module/_cffi_backend/newtype.py +++ b/pypy/module/_cffi_backend/newtype.py @@ -267,7 +267,8 @@ else: if sys.platform == 'win32': DEFAULT_SFLAGS_PLATFORM = SF_MSVC_BITFIELDS else: - if rffi_platform.getdefined('__arm__', ''): + if (rffi_platform.getdefined('__arm__', '') or + rffi_platform.getdefined('__aarch64__', '')): DEFAULT_SFLAGS_PLATFORM = SF_GCC_ARM_BITFIELDS else: DEFAULT_SFLAGS_PLATFORM = SF_GCC_X86_BITFIELDS diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py index cc1d42012e..e3ed6d18c7 100644 --- a/pypy/module/_cffi_backend/test/_backend_test_c.py +++ b/pypy/module/_cffi_backend/test/_backend_test_c.py @@ -1,7 +1,7 @@ # ____________________________________________________________ import sys -assert __version__ == "1.13.1", ("This test_c.py file is for testing a version" +assert __version__ == "1.13.2", ("This test_c.py file is for testing a version" " of cffi that differs from the one that we" " get from 'import _cffi_backend'") if sys.version_info < (3,): diff --git a/pypy/module/_socket/interp_socket.py b/pypy/module/_socket/interp_socket.py index 7db3e824e3..66124e29e1 100644 --- a/pypy/module/_socket/interp_socket.py +++ b/pypy/module/_socket/interp_socket.py @@ -458,7 +458,7 @@ class W_Socket(W_Root): except OperationError as e: if e.async(space): raise - optval = space.bytes_w(w_optval) + optval = space.bufferstr_w(w_optval) try: self.sock.setsockopt(level, optname, optval) except SocketError as e: diff --git a/pypy/module/_socket/test/test_sock_app.py b/pypy/module/_socket/test/test_sock_app.py index 48d05354a6..245a80712b 100644 --- a/pypy/module/_socket/test/test_sock_app.py +++ b/pypy/module/_socket/test/test_sock_app.py @@ -567,6 +567,13 @@ class AppTestSocket: intsize) (reuse,) = struct.unpack('i', reusestr) assert reuse != 0 + # try to call setsockopt() with a buffer argument + reusestr = struct.pack('i', 0) + s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, buffer(reusestr)) + reusestr = s.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, + intsize) + (reuse,) = struct.unpack('i', reusestr) + assert reuse == 0 def test_getsetsockopt_zero(self): # related to issue #2561: when specifying the buffer size param: diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py index 67605e8a45..97f143ba36 100644 --- a/pypy/module/cpyext/api.py +++ b/pypy/module/cpyext/api.py @@ -1195,7 +1195,7 @@ def attach_c_functions(space, eci, prefix): '_PyPy_get_PyOS_InputHook', [], FUNCPTR, compilation_info=eci, _nowrapper=True) state.C.tuple_new = rffi.llexternal( - 'tuple_new', [PyTypeObjectPtr, PyObject, PyObject], PyObject, + '_PyPy_tuple_new', [PyTypeObjectPtr, PyObject, PyObject], PyObject, compilation_info=eci, _nowrapper=True) def init_function(func): diff --git a/pypy/module/cpyext/include/tupleobject.h b/pypy/module/cpyext/include/tupleobject.h index beb9c4e885..6a834d7c61 100644 --- a/pypy/module/cpyext/include/tupleobject.h +++ b/pypy/module/cpyext/include/tupleobject.h @@ -18,7 +18,7 @@ typedef struct { PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size); PyAPI_FUNC(void) _PyPy_tuple_dealloc(PyObject *); -PyAPI_FUNC(PyObject *) tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwds); +PyAPI_FUNC(PyObject *) _PyPy_tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwds); /* defined in varargswrapper.c */ PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...); diff --git a/pypy/module/cpyext/pyerrors.py b/pypy/module/cpyext/pyerrors.py index 4d10db570f..08d680e1ae 100644 --- a/pypy/module/cpyext/pyerrors.py +++ b/pypy/module/cpyext/pyerrors.py @@ -84,11 +84,11 @@ def PyErr_Restore(space, py_type, py_value, py_traceback): w_type = get_w_obj_and_decref(space, py_type) w_value = get_w_obj_and_decref(space, py_value) w_traceback = get_w_obj_and_decref(space, py_traceback) - # XXX do something with w_traceback + if w_type is None: state.clear_exception() return - state.set_exception(OperationError(w_type, w_value)) + state.set_exception(OperationError(w_type, w_value, w_traceback)) @cpython_api([PyObjectP, PyObjectP, PyObjectP], lltype.Void) def PyErr_NormalizeException(space, exc_p, val_p, tb_p): diff --git a/pypy/module/cpyext/src/tupleobject.c b/pypy/module/cpyext/src/tupleobject.c index 3548e713e6..9a67ec2e68 100644 --- a/pypy/module/cpyext/src/tupleobject.c +++ b/pypy/module/cpyext/src/tupleobject.c @@ -94,7 +94,7 @@ static PyObject * tuple_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); PyObject * -tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +_PyPy_tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *arg = NULL; static char *kwlist[] = {"sequence", 0}; @@ -117,7 +117,7 @@ tuple_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) Py_ssize_t i, n; assert(PyType_IsSubtype(type, &PyTuple_Type)); - tmp = tuple_new(&PyTuple_Type, args, kwds); + tmp = _PyPy_tuple_new(&PyTuple_Type, args, kwds); if (tmp == NULL) return NULL; assert(PyTuple_Check(tmp)); diff --git a/pypy/module/cpyext/test/test_pyerrors.py b/pypy/module/cpyext/test/test_pyerrors.py index 67e375c3f3..031407a1b8 100644 --- a/pypy/module/cpyext/test/test_pyerrors.py +++ b/pypy/module/cpyext/test/test_pyerrors.py @@ -3,6 +3,7 @@ import sys import StringIO from pypy.module.cpyext.state import State +from pypy.module.cpyext.pyobject import make_ref from pypy.module.cpyext.test.test_api import BaseApiTest from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase from rpython.rtyper.lltypesystem import rffi @@ -108,6 +109,30 @@ class TestExceptions(BaseApiTest): assert recieved == ['ok'] assert api.PyOS_InterruptOccurred() + def test_restore_traceback(self, space, api): + string = rffi.str2charp("spam and eggs") + api.PyErr_SetString(space.w_ValueError, string) + + state = space.fromcache(State) + operror = state.clear_exception() + + # Fake a traceback. + operror.set_traceback(space.w_True) # this doesn't really need to be a real traceback for this test. + + w_type = operror.w_type + w_value = operror.get_w_value(space) + w_tb = operror.get_w_traceback(space) + + assert not space.eq_w(w_tb, space.w_None) + + api.PyErr_Restore(make_ref(space, w_type), make_ref(space, w_value), make_ref(space, w_tb)) + + operror = state.clear_exception() + w_tb_restored = operror.get_w_traceback(space) + + assert space.eq_w(w_tb_restored, w_tb) + rffi.free_charp(string) + class AppTestFetch(AppTestCpythonExtensionBase): def test_occurred(self): diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py index a59562c940..7b2b831803 100644 --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -452,6 +452,30 @@ class AppTestTypeObject(AppTestCpythonExtensionBase): assert module.hack_tp_dict(obj, "b") == 2 + def test_tp_dict_ready(self): + module = self.import_extension('foo', [ + ("new_obj", "METH_NOARGS", + ''' + PyObject *obj; + obj = PyObject_New(PyObject, &Foo_Type); + return obj; + ''' + )], prologue=''' + static PyTypeObject Foo_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "foo.foo", + }; + ''', more_init = ''' + Foo_Type.tp_flags = Py_TPFLAGS_DEFAULT; + Foo_Type.tp_dict = PyDict_New(); + PyDict_SetItemString(Foo_Type.tp_dict, "inserted", Py_True); + if (PyType_Ready(&Foo_Type) < 0) INITERROR; + ''') + + obj = module.new_obj() + assert type(obj).inserted is True + + def test_tp_descr_get(self): module = self.import_extension('foo', [ ("tp_descr_get", "METH_O", diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py index 7f9bbc577f..1f8ad2e840 100644 --- a/pypy/module/cpyext/typeobject.py +++ b/pypy/module/cpyext/typeobject.py @@ -538,6 +538,13 @@ class W_PyCTypeObject(W_TypeObject): convert_getset_defs(space, dict_w, pto.c_tp_getset, self) convert_member_defs(space, dict_w, pto.c_tp_members, self) + w_dict = from_ref(space, pto.c_tp_dict) + if w_dict is not None: + dictkeys_w = space.listview(w_dict) + for w_key in dictkeys_w: + key = space.text_w(w_key) + dict_w[key] = space.getitem(w_dict, w_key) + name = rffi.charp2str(cts.cast('char*', pto.c_tp_name)) flag_heaptype = pto.c_tp_flags & Py_TPFLAGS_HEAPTYPE if flag_heaptype: @@ -905,8 +912,10 @@ def _type_realize(space, py_obj): # While this is a hack, cpython does it as well. w_metatype = space.w_type - w_obj = space.allocate_instance(W_PyCTypeObject, w_metatype) - track_reference(space, py_obj, w_obj) + w_obj = rawrefcount.to_obj(W_PyCTypeObject, py_obj) + if w_obj is None: + w_obj = space.allocate_instance(W_PyCTypeObject, w_metatype) + track_reference(space, py_obj, w_obj) # __init__ wraps all slotdefs functions from py_type via add_operators w_obj.__init__(space, py_type) w_obj.ready() @@ -933,7 +942,7 @@ def finish_type_1(space, pto, bases_w=None): Sets up tp_bases, necessary before creating the interpreter type. """ base = pto.c_tp_base - base_pyo = rffi.cast(PyObject, pto.c_tp_base) + base_pyo = rffi.cast(PyObject, base) if base and not base.c_tp_flags & Py_TPFLAGS_READY: type_realize(space, base_pyo) if base and not pto.c_ob_type: # will be filled later diff --git a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py index b91aa8787e..1a6f076ce9 100644 --- a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py +++ b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py @@ -18,6 +18,20 @@ def no_vector_backend(): return not detect_simd_z() return True +def align_check(input): + if platform.machine().startswith('x86'): + return "" + if sys.maxsize > 2**32: + mask = 7 + else: + mask = 3 + return """ + i10096 = int_and(%s, %d) + i10097 = int_is_zero(i10096) + guard_true(i10097, descr=...) + """ % (input, mask) + + class TestMicroNumPy(BaseTestPyPyC): arith_comb = [('+','float','float', 4*3427, 3427, 1.0,3.0), @@ -143,8 +157,9 @@ class TestMicroNumPy(BaseTestPyPyC): i9 = getfield_gc_i(p4, descr=<FieldU pypy.module.micronumpy.concrete.BaseConcreteArray.inst_storage \d+ pure>) i10 = getfield_gc_i(p6, descr=<FieldU pypy.module.micronumpy.descriptor.W_Dtype.inst_byteorder \d+ pure>) i12 = int_eq(i10, 61) - i14 = int_eq(i10, %d) + i14 = int_eq(i10, %(bit)d) i15 = int_or(i12, i14) + %(align_check)s f16 = raw_load_f(i9, i5, descr=<ArrayF \d+>) guard_true(i15, descr=...) guard_not_invalidated(descr=...) @@ -176,7 +191,7 @@ class TestMicroNumPy(BaseTestPyPyC): setfield_gc(p34, i30, descr=<FieldS pypy.module.micronumpy.iterators.IterState.inst_offset \d+>) }}} jump(..., descr=...) - """ % (bit,)) + """ % {'align_check': align_check('i5'), 'bit': bit}) def test_reduce_logical_and(self): def main(): @@ -189,6 +204,7 @@ class TestMicroNumPy(BaseTestPyPyC): assert len(log.loops) == 1 loop = log._filter(log.loops[0]) loop.match(""" + %(align_check)s f31 = raw_load_f(i9, i29, descr=<ArrayF 8>) guard_not_invalidated(descr=...) i32 = float_ne(f31, 0.000000) @@ -198,7 +214,7 @@ class TestMicroNumPy(BaseTestPyPyC): i38 = int_ge(i36, i30) guard_false(i38, descr=...) jump(..., descr=...) - """) + """ % {'align_check': align_check('i29')}) # vector version #assert loop.match(""" # guard_not_invalidated(descr=...) @@ -310,6 +326,7 @@ class TestMicroNumPy(BaseTestPyPyC): guard_not_invalidated(descr=...) i88 = int_ge(i87, i59) guard_false(i88, descr=...) + %(align_check)s f90 = raw_load_f(i67, i89, descr=<ArrayF 8>) i91 = int_add(i87, 1) i93 = int_add(i89, 8) @@ -320,7 +337,7 @@ class TestMicroNumPy(BaseTestPyPyC): i96 = int_lt(i95, 0) guard_false(i96, descr=...) jump(..., descr=...) - """) + """ % {"align_check": align_check('i89')}) def test_array_flatiter_getitem_single(self): def main(): @@ -342,6 +359,7 @@ class TestMicroNumPy(BaseTestPyPyC): guard_true(i126, descr=...) i128 = int_mul(i117, i59) i129 = int_add(i55, i128) + %(align_check)s f149 = raw_load_f(i100, i129, descr=<ArrayF 8>) i151 = int_add(i117, 1) setfield_gc(p156, i55, descr=<FieldS pypy.module.micronumpy.iterators.IterState.inst_offset .+>) @@ -349,7 +367,7 @@ class TestMicroNumPy(BaseTestPyPyC): setarrayitem_gc(p150, 0, 0, descr=<ArrayS .+>) --TICK-- jump(..., descr=...) - """) + """ % {'align_check': align_check('i129')}) def test_array_flatiter_setitem_single(self): def main(): @@ -372,6 +390,7 @@ class TestMicroNumPy(BaseTestPyPyC): i131 = int_mul(i120, i57) i132 = int_add(i53, i131) guard_not_invalidated(descr=...) + %(align_check)s raw_store(i103, i132, 42.000000, descr=<ArrayF 8>) i153 = int_add(i120, 1) i154 = getfield_raw_i(#, descr=<FieldS pypysig_long_struct.c_value 0>) @@ -381,7 +400,7 @@ class TestMicroNumPy(BaseTestPyPyC): i157 = int_lt(i154, 0) guard_false(i157, descr=...) jump(..., descr=...) - """) + """ % {'align_check': align_check('i132')}) def test_mixed_div(self): N = 1500 @@ -405,6 +424,7 @@ class TestMicroNumPy(BaseTestPyPyC): guard_false(i94, descr=...) i96 = int_mul(i91, i58) i97 = int_add(i51, i96) + %(align_check)s f98 = raw_load_f(i63, i97, descr=<ArrayF 8>) guard_not_invalidated(descr=...) f100 = float_mul(f98, 0.500000) @@ -422,4 +442,4 @@ class TestMicroNumPy(BaseTestPyPyC): i107 = int_lt(i106, 0) guard_false(i107, descr=...) jump(..., descr=...) - """) + """ % {'align_check': align_check('i97')}) diff --git a/pypy/tool/build_cffi_imports.py b/pypy/tool/build_cffi_imports.py index caded34273..489dfb5ea8 100644 --- a/pypy/tool/build_cffi_imports.py +++ b/pypy/tool/build_cffi_imports.py @@ -24,7 +24,19 @@ cffi_build_scripts = { # the OS, such as a recent openssl/libressl. curdir = os.path.abspath(os.path.dirname(__file__)) deps_destdir = os.path.join(curdir, 'dest') +configure_args = ['./configure', + '--prefix=/usr', + '--disable-shared', + '--enable-silent-rules', + '--disable-dependency-tracking', + ] cffi_dependencies = { + 'lzma': ('https://tukaani.org/xz/xz-5.2.3.tar.gz', + '71928b357d0a09a12a4b4c5fafca8c31c19b0e7d3b8ebb19622e96f26dbf28cb', + [configure_args, + ['make', '-s', '-j', str(multiprocessing.cpu_count())], + ['make', 'install', 'DESTDIR={}/'.format(deps_destdir)], + ]), '_ssl': ('https://www.openssl.org/source/openssl-1.1.1c.tar.gz', 'f6fb3079ad15076154eda9413fed42877d668e7069d9b87396d0804fdb3f4c90', [['./config', '--prefix=/usr', 'no-shared'], @@ -33,7 +45,7 @@ cffi_dependencies = { ]), '_gdbm': ('http://ftp.gnu.org/gnu/gdbm/gdbm-1.13.tar.gz', '9d252cbd7d793f7b12bcceaddda98d257c14f4d1890d851c386c37207000a253', - [['./config', '--without-readline'], + [configure_args, ['make', '-s', '-j', str(multiprocessing.cpu_count())], ['make', 'install', 'DESTDIR={}/'.format(deps_destdir)], ]), @@ -176,8 +188,11 @@ def create_cffi_import_libraries(pypy_c, options, basedir, only=None, status, stdout, stderr = run_subprocess(str(pypy_c), args, cwd=cwd, env=env) if status != 0: - print(stdout, stderr, file=sys.stderr) failures.append((key, module)) + print("stdout:") + print(stdout, file=sys.stderr) + print("stderr:") + print(stderr, file=sys.stderr) except: import traceback;traceback.print_exc() failures.append((key, module)) diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py index d1cfffb093..5b2b8d085c 100755 --- a/pypy/tool/release/package.py +++ b/pypy/tool/release/package.py @@ -30,6 +30,8 @@ USE_ZIPFILE_MODULE = sys.platform == 'win32' STDLIB_VER = "2.7" +POSIX_EXE = 'pypy' + from pypy.tool.build_cffi_imports import (create_cffi_import_libraries, MissingDependenciesError, cffi_build_scripts) @@ -71,7 +73,7 @@ def create_package(basedir, options, _fake=False): basedir = py.path.local(basedir) if not override_pypy_c: - basename = 'pypy-c' + basename = POSIX_EXE + '-c' if sys.platform == 'win32': basename += '.exe' pypy_c = basedir.join('pypy', 'goal', basename) @@ -106,10 +108,13 @@ def create_package(basedir, options, _fake=False): if (sys.platform != 'win32' and # handled below not _fake and os.path.getsize(str(pypy_c)) < 500000): - # This pypy-c is very small, so it means it relies on libpypy_c.so. + # This 'pypy_c' is very small, so it means it relies on a so/dll # If it would be bigger, it wouldn't. That's a hack. - libpypy_name = ('libpypy-c.so' if not sys.platform.startswith('darwin') - else 'libpypy-c.dylib') + if sys.platform.startswith('darwin'): + ext = 'dylib' + else: + ext = 'so' + libpypy_name = 'lib' + POSIX_EXE + '-c.' + ext libpypy_c = pypy_c.new(basename=libpypy_name) if not libpypy_c.check(): raise PyPyCNotFound('Expected pypy to be mostly in %r, but did ' @@ -134,8 +139,9 @@ def create_package(basedir, options, _fake=False): tgt = py.path.local(tgt) binaries.append((pypyw, tgt.new(purebasename=tgt.purebasename + 'w').basename, None)) print("Picking %s" % str(pypyw)) - # Can't rename a DLL: it is always called 'libpypy-c.dll' - win_extras = [('libpypy-c.dll', None), ('sqlite3.dll', lib_pypy)] + # Can't rename a DLL + win_extras = [('lib' + POSIX_EXE + '-c.dll', None), + ('sqlite3.dll', lib_pypy)] if not options.no_tk: tkinter_dir = lib_pypy.join('_tkinter') win_extras += [('tcl85.dll', tkinter_dir), ('tk85.dll', tkinter_dir)] @@ -155,9 +161,8 @@ def create_package(basedir, options, _fake=False): print('Picking %s (and contents)' % libsdir) shutil.copytree(str(libsdir), str(pypydir.join('libs'))) else: - print('"libs" dir with import library not found.') - print('You have to create %r' % (str(libsdir),)) - print('and copy libpypy-c.lib in there, renamed to python27.lib') + if not _fake: + raise RuntimeError('"libs" dir with import library not found.') # XXX users will complain that they cannot compile capi (cpyext) # modules for windows, also embedding pypy (i.e. in cffi) # will fail. @@ -185,14 +190,14 @@ def create_package(basedir, options, _fake=False): for source, target, target_dir in binaries]) # Careful: to copy lib_pypy, copying just the hg-tracked files - # would not be enough: there are also ctypes_config_cache/_*_cache.py. - # XXX ^^^ this is no longer true! + # would not be enough: there are also build artifacts like cffi-generated + # dynamic libs shutil.copytree(str(basedir.join('lib-python').join(STDLIB_VER)), str(pypydir.join('lib-python').join(STDLIB_VER)), ignore=ignore_patterns('.svn', 'py', '*.pyc', '*~')) shutil.copytree(str(basedir.join('lib_pypy')), str(lib_pypy), ignore=ignore_patterns('.svn', 'py', '*.pyc', '*~', - '*_cffi.c', '*.o')) + '*_cffi.c', '*.o', '*.pyd-*')) for file in ['README.rst',]: shutil.copy(str(basedir.join(file)), str(pypydir)) for file in ['_testcapimodule.c', '_ctypes_test.c']: @@ -223,6 +228,14 @@ def create_package(basedir, options, _fake=False): else: open(str(archive), 'wb').close() os.chmod(str(archive), 0755) + #if not _fake and not sys.platform == 'win32': + # # create the pypy3 symlink + # old_dir = os.getcwd() + # os.chdir(str(bindir)) + # try: + # os.symlink(POSIX_EXE, 'pypy3') + # finally: + # os.chdir(old_dir) fix_permissions(pypydir) old_dir = os.getcwd() @@ -292,9 +305,9 @@ def package(*args, **kwds): setattr(ns, self.dest, option[2:4] != 'no') if sys.platform == 'win32': - pypy_exe = 'pypy.exe' + pypy_exe = POSIX_EXE + '.exe' else: - pypy_exe = 'pypy' + pypy_exe = POSIX_EXE parser = argparse.ArgumentParser() args = list(args) if args: diff --git a/pypy/tool/release/test/test_package.py b/pypy/tool/release/test/test_package.py index 27b4120170..f030264e57 100644 --- a/pypy/tool/release/test/test_package.py +++ b/pypy/tool/release/test/test_package.py @@ -1,4 +1,4 @@ - +import os import py from pypy import pypydir from pypy.tool.release import package @@ -15,8 +15,8 @@ class TestPackaging: cls.exe_name_in_archive = 'pypy-c.exe' else: basename = 'pypy-c' - cls.rename_pypy_c = 'pypy' - cls.exe_name_in_archive = 'bin/pypy' + cls.rename_pypy_c = package.POSIX_EXE + cls.exe_name_in_archive = os.path.join('bin', package.POSIX_EXE) cls.pypy_c = py.path.local(pypydir).join('goal', basename) def test_dir_structure(self, test='test'): diff --git a/rpython/jit/backend/x86/rx86.py b/rpython/jit/backend/x86/rx86.py index fa418066e1..dab110fe7d 100644 --- a/rpython/jit/backend/x86/rx86.py +++ b/rpython/jit/backend/x86/rx86.py @@ -699,6 +699,9 @@ class AbstractX86CodeBuilder(object): TEST_ai = insn(rex_w, '\xF7', orbyte(0<<3), mem_reg_plus_scaled_reg_plus_const(1), immediate(2)) TEST_mi = insn(rex_w, '\xF7', orbyte(0<<3), mem_reg_plus_const(1), immediate(2)) TEST_ji = insn(rex_w, '\xF7', orbyte(0<<3), abs_(1), immediate(2)) + TEST_ri = insn(rex_w, '\xF7', orbyte(0<<3), register(1), '\xC0', immediate(2)) + TEST_bi = insn(rex_w, '\xF7', orbyte(0<<3), stack_bp(1), immediate(2)) + TEST_br = insn(rex_w, '\x85', register(2,8), stack_bp(1)) BTS_mr = insn(rex_w, '\x0F\xAB', register(2,8), mem_reg_plus_const(1)) BTS_jr = insn(rex_w, '\x0F\xAB', register(2,8), abs_(1)) diff --git a/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py b/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py index 89cf36f2da..e8819996c7 100644 --- a/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py +++ b/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py @@ -311,6 +311,8 @@ class TestRx86_32(object): return [] # MOV AL, [immediate]: there is a special encoding if methname == 'MOV8_jr' and args[1] == rx86.R.al: return [] # MOV [immediate], AL: there is a special encoding + if methname == 'TEST_ri' and args[0] == rx86.R.eax: + return [] # TEST EAX, constant: there is a special encoding return [args] diff --git a/rpython/rlib/compilerinfo.py b/rpython/rlib/compilerinfo.py index 700d548981..bd18ebcbc5 100644 --- a/rpython/rlib/compilerinfo.py +++ b/rpython/rlib/compilerinfo.py @@ -18,8 +18,8 @@ def get_compiler_info(): if platform.name == 'msvc': - # XXX hard-code the MSC version, I don't feel like computing it dynamically - _C_COMPILER_INFO = '"MSC v.%d 32 bit"' % (platform.version * 10 + 600) + # XXX hard-code the bit name + _C_COMPILER_INFO = '"MSC v." Py_STR(_MSC_VER) " 32 bit"' else: _C_COMPILER_INFO = '("GCC " __VERSION__)' diff --git a/rpython/rlib/rsre/rsre_core.py b/rpython/rlib/rsre/rsre_core.py index f03e3c9254..e9a02eed6a 100644 --- a/rpython/rlib/rsre/rsre_core.py +++ b/rpython/rlib/rsre/rsre_core.py @@ -96,8 +96,10 @@ class CompiledPattern(object): def __init__(self, pattern): self.pattern = pattern # check we don't get the old value of MAXREPEAT - # during the untranslated tests - if not we_are_translated(): + # during the untranslated tests. + # On python3, MAXCODE can appear in patterns. It will be 65535 + # when CODESIZE is 2 + if not we_are_translated() and rsre_char.CODESIZE != 2: assert 65535 not in pattern def pat(self, index): diff --git a/rpython/rlib/rstring.py b/rpython/rlib/rstring.py index e2ac19774c..583dcfa27b 100644 --- a/rpython/rlib/rstring.py +++ b/rpython/rlib/rstring.py @@ -601,6 +601,11 @@ class NumberStringParser: assert i >= self.start self.i = i c = self.s[i] + if self.allow_underscores and c == '_': + i = self.i - 1 + assert i >= 0 + self.i = i + c = self.s[i] digit = ord(c) if '0' <= c <= '9': digit -= ord('0') diff --git a/rpython/rlib/rwin32.py b/rpython/rlib/rwin32.py index e714f220c5..fc6cc1fb55 100644 --- a/rpython/rlib/rwin32.py +++ b/rpython/rlib/rwin32.py @@ -114,6 +114,7 @@ class CConfig: WC_NO_BEST_FIT_CHARS STD_INPUT_HANDLE STD_OUTPUT_HANDLE STD_ERROR_HANDLE HANDLE_FLAG_INHERIT FILE_TYPE_CHAR LOAD_WITH_ALTERED_SEARCH_PATH + CP_ACP CP_UTF8 CP_UTF7 CP_OEMCP MB_ERR_INVALID_CHARS """ from rpython.translator.platform import host_factory static_platform = host_factory() diff --git a/rpython/translator/c/src/commondefs.h b/rpython/translator/c/src/commondefs.h index e9b49a0b45..bea03e9d58 100644 --- a/rpython/translator/c/src/commondefs.h +++ b/rpython/translator/c/src/commondefs.h @@ -123,3 +123,7 @@ # define MS_WINDOWS /* a synonym */ #endif #endif + +/* stringify a constant */ +#define Py_XSTR(x) #x +#define Py_STR(x) Py_XSTR(x) |