Author: Matti Picus <matti.pi...@gmail.com> Branch: unicode-utf8-py3 Changeset: r95661:f751ef782eeb Date: 2019-01-17 00:43 +0200 http://bitbucket.org/pypy/pypy/changeset/f751ef782eeb/
Log: merge py3.5 into branch diff --git a/extra_tests/test_bufferedreader.py b/extra_tests/test_bufferedreader.py --- a/extra_tests/test_bufferedreader.py +++ b/extra_tests/test_bufferedreader.py @@ -88,7 +88,7 @@ assert self.stream.readline(80) == expected @pytest.mark.parametrize('StreamCls', [Stream, StreamCFFI]) -@settings(max_examples=50) +@settings(max_examples=50, deadline=None) @given(params=data_and_sizes(), chunk_size=st.integers(MIN_READ_SIZE, 8192)) def test_stateful(params, chunk_size, StreamCls): data, sizes = params diff --git a/extra_tests/test_datetime.py b/extra_tests/test_datetime.py --- a/extra_tests/test_datetime.py +++ b/extra_tests/test_datetime.py @@ -33,7 +33,9 @@ (timedelta_safe(1, 2, 3), "timedelta_safe(1, 2, 3)"), ]) def test_repr(obj, expected): - assert repr(obj) == expected + # XXX: there's a discrepancy between datetime.py and CPython's _datetime + # for the repr() of Python-defined subclasses of datetime classes. + assert repr(obj).endswith(expected) @pytest.mark.parametrize("obj", [ datetime.date.today(), diff --git a/lib_pypy/_ctypes/primitive.py b/lib_pypy/_ctypes/primitive.py --- a/lib_pypy/_ctypes/primitive.py +++ b/lib_pypy/_ctypes/primitive.py @@ -410,6 +410,6 @@ id(self)) def __bool__(self): - return self._buffer[0] not in (0, '\x00') + return self._buffer[0] not in (0, b'\x00') from _ctypes.function import CFuncPtr diff --git a/lib_pypy/_gdbm.py b/lib_pypy/_gdbm.py --- a/lib_pypy/_gdbm.py +++ b/lib_pypy/_gdbm.py @@ -74,12 +74,11 @@ self.__check_closed() key = _checkstr(key) return lib.pygdbm_exists(self.__ll_dbm, key, len(key)) - has_key = __contains__ def get(self, key, default=None): with _lock: self.__check_closed() - key = _checkstr(key) + key = _checkstr(key) drec = lib.pygdbm_fetch(self.__ll_dbm, key, len(key)) if not drec.dptr: return default diff --git a/pypy/conftest.py b/pypy/conftest.py --- a/pypy/conftest.py +++ b/pypy/conftest.py @@ -14,6 +14,14 @@ rsyncdirs = ['.', '../lib-python', '../lib_pypy', '../demo'] rsyncignore = ['_cache'] +try: + from hypothesis import settings +except ImportError: + pass +else: + settings.register_profile('default', deadline=None) + settings.load_profile('default') + # PyPy's command line extra options (these are added # to py.test's standard options) # diff --git a/pypy/module/__pypy__/test/test_builders.py b/pypy/module/__pypy__/test/test_builders.py --- a/pypy/module/__pypy__/test/test_builders.py +++ b/pypy/module/__pypy__/test/test_builders.py @@ -4,33 +4,32 @@ def test_simple(self): from __pypy__.builders import StringBuilder b = StringBuilder() - b.append("abc") - b.append("123") - b.append("1") + b.append(u"abc") + b.append(u"123") + b.append(u"1") s = b.build() - assert s == "abc1231" - assert type(s) is str + assert s == u"abc1231" assert b.build() == s - b.append("123") - assert b.build() == s + "123" + b.append(u"123") + assert b.build() == s + u"123" def test_preallocate(self): from __pypy__.builders import StringBuilder b = StringBuilder(10) - b.append("abc") - b.append("123") + b.append(u"abc") + b.append(u"123") s = b.build() - assert s == "abc123" + assert s == u"abc123" def test_append_slice(self): from __pypy__.builders import StringBuilder b = StringBuilder() - b.append_slice("abcdefgh", 2, 5) - raises(ValueError, b.append_slice, "1", 2, 1) + b.append_slice(u"abcdefgh", 2, 5) + raises(ValueError, b.append_slice, u"1", 2, 1) s = b.build() - assert s == "cde" - b.append_slice("abc", 1, 2) - assert b.build() == "cdeb" + assert s == u"cde" + b.append_slice(u"abc", 1, 2) + assert b.build() == u"cdeb" def test_stringbuilder(self): from __pypy__.builders import BytesBuilder diff --git a/rpython/translator/platform/windows.py b/rpython/translator/platform/windows.py --- a/rpython/translator/platform/windows.py +++ b/rpython/translator/platform/windows.py @@ -9,14 +9,14 @@ import rpython rpydir = str(py.path.local(rpython.__file__).join('..')) -def _get_compiler_type(cc, x64_flag, ver0=None): +def _get_compiler_type(cc, x64_flag): if not cc: cc = os.environ.get('CC','') if not cc: - return MsvcPlatform(x64=x64_flag, ver0=ver0) + return MsvcPlatform(x64=x64_flag) elif cc.startswith('mingw') or cc == 'gcc': return MingwPlatform(cc) - return MsvcPlatform(cc=cc, x64=x64_flag, ver0=ver0) + return MsvcPlatform(cc=cc, x64=x64_flag) def _get_vcver0(): # try to get the compiler which served to compile python @@ -28,17 +28,13 @@ return vsver return None -def Windows(cc=None, ver0=None): - #if ver0 is None: - # ver0 = _get_vcver0() - return _get_compiler_type(cc, False, ver0=ver0) +def Windows(cc=None): + return _get_compiler_type(cc, False) def Windows_x64(cc=None, ver0=None): raise Exception("Win64 is not supported. You must either build for Win32" " or contribute the missing support in PyPy.") - if ver0 is None: - ver0 = _get_vcver0() - return _get_compiler_type(cc, True, ver0=ver0) + return _get_compiler_type(cc, True) def _find_vcvarsall(version, x64flag): import rpython.tool.setuptools_msvc as msvc @@ -50,7 +46,7 @@ return msvc.msvc14_get_vc_env(arch) else: return msvc.msvc9_query_vcvarsall(version / 10.0, arch) - + def _get_msvc_env(vsver, x64flag): vcdict = None toolsdir = None @@ -74,7 +70,7 @@ # even msdn does not know which to run # see https://msdn.microsoft.com/en-us/library/1700bbwd(v=vs.90).aspx # which names both - vcvars = os.path.join(toolsdir, 'vcvars32.bat') + vcvars = os.path.join(toolsdir, 'vcvars32.bat') import subprocess try: @@ -83,12 +79,14 @@ stderr=subprocess.PIPE) stdout, stderr = popen.communicate() - if popen.wait() != 0: + if popen.wait() != 0 or stdout[:5].lower() == 'error': + log.msg('Running "%s" errored: \n\nstdout:\n%s\n\nstderr:\n%s' % ( + vcvars, stdout.split()[0], stderr)) return None - if stdout[:5].lower() == 'error': - log.msg('Running "%s" errored: %s' %(vcvars, stdout.split()[0])) - return None - except: + else: + log.msg('Running "%s" succeeded' %(vcvars,)) + except Exception as e: + log.msg('Running "%s" failed: "%s"', (vcvars, str(e))) return None stdout = stdout.replace("\r\n", "\n") @@ -102,6 +100,8 @@ for key, value in vcdict.items(): if key.upper() in ['PATH', 'INCLUDE', 'LIB']: env[key.upper()] = value + if 'PATH' not in env: + log.msg('Did not find "PATH" in stdout\n%s' %(stdout)) if not _find_executable('mt.exe', env['PATH']): # For some reason the sdk bin path is missing? # put it together from some other env variables that happened to exist @@ -113,7 +113,7 @@ log.msg('Could not find mt.exe on path=%s' % env['PATH']) log.msg('Running vsver %s set this env' % vsver) for key, value in vcdict.items(): - log.msg('%s=%s' %(key, value)) + log.msg('%s=%s' %(key, value)) log.msg("Updated environment with vsver %d, using x64 %s" % (vsver, x64flag,)) return env @@ -122,7 +122,7 @@ if ver0 in vcvers: vcvers.insert(0, ver0) errs = [] - for vsver in vcvers: + for vsver in vcvers: env = _get_msvc_env(vsver, x64flag) if env is not None: return env, vsver @@ -189,8 +189,13 @@ self.cc = cc # detect version of current compiler - returncode, stdout, stderr = _run_subprocess(self.cc, [], + try: + returncode, stdout, stderr = _run_subprocess(self.cc, [], env=self.c_environ) + except EnvironmentError: + log.msg('Could not run %s using PATH=\n%s' %(self.cc, + '\n'.join(self.c_environ['PATH'].split(';')))) + raise r = re.search(r'Microsoft.+C/C\+\+.+\s([0-9]+)\.([0-9]+).*', stderr) if r is not None: self.version = int(''.join(r.groups())) / 10 - 60 @@ -276,23 +281,21 @@ if not standalone: args = self._args_for_shared(args) - if self.version >= 80: - # Tell the linker to generate a manifest file - temp_manifest = exe_name.dirpath().join( - exe_name.purebasename + '.manifest') - args += ["/MANIFEST", "/MANIFESTFILE:%s" % (temp_manifest,)] + # Tell the linker to generate a manifest file + temp_manifest = exe_name.dirpath().join( + exe_name.purebasename + '.manifest') + args += ["/MANIFEST", "/MANIFESTFILE:%s" % (temp_manifest,)] self._execute_c_compiler(self.link, args, exe_name) - if self.version >= 80: - # Now, embed the manifest into the program - if standalone: - mfid = 1 - else: - mfid = 2 - out_arg = '-outputresource:%s;%s' % (exe_name, mfid) - args = ['-nologo', '-manifest', str(temp_manifest), out_arg] - self._execute_c_compiler('mt.exe', args, exe_name) + # Now, embed the manifest into the program + if standalone: + mfid = 1 + else: + mfid = 2 + out_arg = '-outputresource:%s;%s' % (exe_name, mfid) + args = ['-nologo', '-manifest', str(temp_manifest), out_arg] + self._execute_c_compiler('mt.exe', args, exe_name) return exe_name @@ -396,7 +399,7 @@ if len(headers_to_precompile)>0: if shared: - no_precompile_cfiles += [m.makefile_dir / 'main.c', + no_precompile_cfiles += [m.makefile_dir / 'main.c', m.makefile_dir / 'wmain.c'] stdafx_h = path.join('stdafx.h') txt = '#ifndef PYPY_STDAFX_H\n' _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit