Author: Ronan Lamy <ronan.l...@gmail.com> Branch: py3.6 Changeset: r95139:39e4b5e92c6c Date: 2018-09-19 02:26 +0100 http://bitbucket.org/pypy/pypy/changeset/39e4b5e92c6c/
Log: hg merge py3.5 diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst --- a/pypy/doc/cpython_differences.rst +++ b/pypy/doc/cpython_differences.rst @@ -330,7 +330,8 @@ ------------- * Hash randomization (``-R``) `is ignored in PyPy`_. In CPython - before 3.4 it has `little point`_. + before 3.4 it has `little point`_. Both CPython >= 3.4 and PyPy3 + implement the randomized SipHash algorithm and ignore ``-R``. * You can't store non-string keys in type objects. For example:: diff --git a/pypy/module/_csv/interp_reader.py b/pypy/module/_csv/interp_reader.py --- a/pypy/module/_csv/interp_reader.py +++ b/pypy/module/_csv/interp_reader.py @@ -73,6 +73,9 @@ break raise self.line_num += 1 + if space.isinstance_w(w_line, space.w_bytes): + raise self.error(u"iterator should return strings, not bytes " + u"(did you open the file in text mode?") line = space.unicode_w(w_line) for c in line: if c == u'\0': diff --git a/pypy/module/_csv/test/test_reader.py b/pypy/module/_csv/test/test_reader.py --- a/pypy/module/_csv/test/test_reader.py +++ b/pypy/module/_csv/test/test_reader.py @@ -33,7 +33,7 @@ def test_cannot_read_bytes(self): import _csv reader = _csv.reader([b'foo']) - raises((TypeError, _csv.Error), next, reader) + raises(_csv.Error, next, reader) def test_read_oddinputs(self): self._read_test([], []) diff --git a/pypy/module/cpyext/test0/test_arraymodule.py b/pypy/module/cpyext/test/test_arraymodule.py rename from pypy/module/cpyext/test0/test_arraymodule.py rename to pypy/module/cpyext/test/test_arraymodule.py diff --git a/pypy/module/cpyext/test0/test_boolobject.py b/pypy/module/cpyext/test/test_boolobject.py rename from pypy/module/cpyext/test0/test_boolobject.py rename to pypy/module/cpyext/test/test_boolobject.py diff --git a/pypy/module/cpyext/test0/test_borrow.py b/pypy/module/cpyext/test/test_borrow.py rename from pypy/module/cpyext/test0/test_borrow.py rename to pypy/module/cpyext/test/test_borrow.py diff --git a/pypy/module/cpyext/test0/test_bytearrayobject.py b/pypy/module/cpyext/test/test_bytearrayobject.py rename from pypy/module/cpyext/test0/test_bytearrayobject.py rename to pypy/module/cpyext/test/test_bytearrayobject.py diff --git a/pypy/module/cpyext/test0/test_bytesobject.py b/pypy/module/cpyext/test/test_bytesobject.py rename from pypy/module/cpyext/test0/test_bytesobject.py rename to pypy/module/cpyext/test/test_bytesobject.py diff --git a/pypy/module/cpyext/test0/test_capsule.py b/pypy/module/cpyext/test/test_capsule.py rename from pypy/module/cpyext/test0/test_capsule.py rename to pypy/module/cpyext/test/test_capsule.py diff --git a/pypy/module/cpyext/test0/test_cell.py b/pypy/module/cpyext/test/test_cell.py rename from pypy/module/cpyext/test0/test_cell.py rename to pypy/module/cpyext/test/test_cell.py diff --git a/pypy/module/cpyext/test0/test_classobject.py b/pypy/module/cpyext/test/test_classobject.py rename from pypy/module/cpyext/test0/test_classobject.py rename to pypy/module/cpyext/test/test_classobject.py diff --git a/pypy/module/cpyext/test0/test_codecs.py b/pypy/module/cpyext/test/test_codecs.py rename from pypy/module/cpyext/test0/test_codecs.py rename to pypy/module/cpyext/test/test_codecs.py diff --git a/pypy/module/cpyext/test0/test_complexobject.py b/pypy/module/cpyext/test/test_complexobject.py rename from pypy/module/cpyext/test0/test_complexobject.py rename to pypy/module/cpyext/test/test_complexobject.py diff --git a/pypy/module/cpyext/test0/test_cparser.py b/pypy/module/cpyext/test/test_cparser.py rename from pypy/module/cpyext/test0/test_cparser.py rename to pypy/module/cpyext/test/test_cparser.py diff --git a/pypy/module/cpyext/test0/test_datetime.py b/pypy/module/cpyext/test/test_datetime.py rename from pypy/module/cpyext/test0/test_datetime.py rename to pypy/module/cpyext/test/test_datetime.py diff --git a/pypy/module/cpyext/test0/test_dictobject.py b/pypy/module/cpyext/test/test_dictobject.py rename from pypy/module/cpyext/test0/test_dictobject.py rename to pypy/module/cpyext/test/test_dictobject.py diff --git a/pypy/module/cpyext/test0/test_eval.py b/pypy/module/cpyext/test/test_eval.py rename from pypy/module/cpyext/test0/test_eval.py rename to pypy/module/cpyext/test/test_eval.py diff --git a/pypy/module/cpyext/test0/test_fileobject.py b/pypy/module/cpyext/test/test_fileobject.py rename from pypy/module/cpyext/test0/test_fileobject.py rename to pypy/module/cpyext/test/test_fileobject.py diff --git a/pypy/module/cpyext/test0/test_floatobject.py b/pypy/module/cpyext/test/test_floatobject.py rename from pypy/module/cpyext/test0/test_floatobject.py rename to pypy/module/cpyext/test/test_floatobject.py diff --git a/pypy/module/cpyext/test0/test_frameobject.py b/pypy/module/cpyext/test/test_frameobject.py rename from pypy/module/cpyext/test0/test_frameobject.py rename to pypy/module/cpyext/test/test_frameobject.py diff --git a/pypy/module/cpyext/test0/test_funcobject.py b/pypy/module/cpyext/test/test_funcobject.py rename from pypy/module/cpyext/test0/test_funcobject.py rename to pypy/module/cpyext/test/test_funcobject.py diff --git a/pypy/module/cpyext/test0/test_genobject.py b/pypy/module/cpyext/test/test_genobject.py rename from pypy/module/cpyext/test0/test_genobject.py rename to pypy/module/cpyext/test/test_genobject.py diff --git a/pypy/module/cpyext/test0/test_getargs.py b/pypy/module/cpyext/test/test_getargs.py rename from pypy/module/cpyext/test0/test_getargs.py rename to pypy/module/cpyext/test/test_getargs.py diff --git a/pypy/module/cpyext/test0/test_import.py b/pypy/module/cpyext/test/test_import.py rename from pypy/module/cpyext/test0/test_import.py rename to pypy/module/cpyext/test/test_import.py diff --git a/pypy/module/cpyext/test0/test_iterator.py b/pypy/module/cpyext/test/test_iterator.py rename from pypy/module/cpyext/test0/test_iterator.py rename to pypy/module/cpyext/test/test_iterator.py diff --git a/pypy/module/cpyext/test0/test_listobject.py b/pypy/module/cpyext/test/test_listobject.py rename from pypy/module/cpyext/test0/test_listobject.py rename to pypy/module/cpyext/test/test_listobject.py diff --git a/pypy/module/cpyext/test0/test_longobject.py b/pypy/module/cpyext/test/test_longobject.py rename from pypy/module/cpyext/test0/test_longobject.py rename to pypy/module/cpyext/test/test_longobject.py diff --git a/pypy/module/cpyext/test0/test_mapping.py b/pypy/module/cpyext/test/test_mapping.py rename from pypy/module/cpyext/test0/test_mapping.py rename to pypy/module/cpyext/test/test_mapping.py diff --git a/pypy/module/cpyext/test0/test_marshal.py b/pypy/module/cpyext/test/test_marshal.py rename from pypy/module/cpyext/test0/test_marshal.py rename to pypy/module/cpyext/test/test_marshal.py diff --git a/pypy/module/cpyext/test0/test_memoryobject.py b/pypy/module/cpyext/test/test_memoryobject.py rename from pypy/module/cpyext/test0/test_memoryobject.py rename to pypy/module/cpyext/test/test_memoryobject.py diff --git a/pypy/module/cpyext/test0/test_methodobject.py b/pypy/module/cpyext/test/test_methodobject.py rename from pypy/module/cpyext/test0/test_methodobject.py rename to pypy/module/cpyext/test/test_methodobject.py diff --git a/pypy/module/cpyext/test0/test_module.py b/pypy/module/cpyext/test/test_module.py rename from pypy/module/cpyext/test0/test_module.py rename to pypy/module/cpyext/test/test_module.py diff --git a/pypy/module/cpyext/test0/test_ndarrayobject.py b/pypy/module/cpyext/test/test_ndarrayobject.py rename from pypy/module/cpyext/test0/test_ndarrayobject.py rename to pypy/module/cpyext/test/test_ndarrayobject.py diff --git a/pypy/module/cpyext/test0/test_number.py b/pypy/module/cpyext/test/test_number.py rename from pypy/module/cpyext/test0/test_number.py rename to pypy/module/cpyext/test/test_number.py diff --git a/pypy/module/cpyext/test1/test_object.py b/pypy/module/cpyext/test/test_object.py rename from pypy/module/cpyext/test1/test_object.py rename to pypy/module/cpyext/test/test_object.py diff --git a/pypy/module/cpyext/test1/test_pycobject.py b/pypy/module/cpyext/test/test_pycobject.py rename from pypy/module/cpyext/test1/test_pycobject.py rename to pypy/module/cpyext/test/test_pycobject.py diff --git a/pypy/module/cpyext/test1/test_pyerrors.py b/pypy/module/cpyext/test/test_pyerrors.py rename from pypy/module/cpyext/test1/test_pyerrors.py rename to pypy/module/cpyext/test/test_pyerrors.py diff --git a/pypy/module/cpyext/test1/test_pyfile.py b/pypy/module/cpyext/test/test_pyfile.py rename from pypy/module/cpyext/test1/test_pyfile.py rename to pypy/module/cpyext/test/test_pyfile.py diff --git a/pypy/module/cpyext/test1/test_pysignals.py b/pypy/module/cpyext/test/test_pysignals.py rename from pypy/module/cpyext/test1/test_pysignals.py rename to pypy/module/cpyext/test/test_pysignals.py diff --git a/pypy/module/cpyext/test1/test_pystate.py b/pypy/module/cpyext/test/test_pystate.py rename from pypy/module/cpyext/test1/test_pystate.py rename to pypy/module/cpyext/test/test_pystate.py diff --git a/pypy/module/cpyext/test1/test_pystrtod.py b/pypy/module/cpyext/test/test_pystrtod.py rename from pypy/module/cpyext/test1/test_pystrtod.py rename to pypy/module/cpyext/test/test_pystrtod.py diff --git a/pypy/module/cpyext/test1/test_sequence.py b/pypy/module/cpyext/test/test_sequence.py rename from pypy/module/cpyext/test1/test_sequence.py rename to pypy/module/cpyext/test/test_sequence.py diff --git a/pypy/module/cpyext/test1/test_setobject.py b/pypy/module/cpyext/test/test_setobject.py rename from pypy/module/cpyext/test1/test_setobject.py rename to pypy/module/cpyext/test/test_setobject.py diff --git a/pypy/module/cpyext/test1/test_sliceobject.py b/pypy/module/cpyext/test/test_sliceobject.py rename from pypy/module/cpyext/test1/test_sliceobject.py rename to pypy/module/cpyext/test/test_sliceobject.py diff --git a/pypy/module/cpyext/test1/test_structseq.py b/pypy/module/cpyext/test/test_structseq.py rename from pypy/module/cpyext/test1/test_structseq.py rename to pypy/module/cpyext/test/test_structseq.py diff --git a/pypy/module/cpyext/test1/test_sysmodule.py b/pypy/module/cpyext/test/test_sysmodule.py rename from pypy/module/cpyext/test1/test_sysmodule.py rename to pypy/module/cpyext/test/test_sysmodule.py diff --git a/pypy/module/cpyext/test1/test_thread.py b/pypy/module/cpyext/test/test_thread.py rename from pypy/module/cpyext/test1/test_thread.py rename to pypy/module/cpyext/test/test_thread.py diff --git a/pypy/module/cpyext/test1/test_traceback.py b/pypy/module/cpyext/test/test_traceback.py rename from pypy/module/cpyext/test1/test_traceback.py rename to pypy/module/cpyext/test/test_traceback.py diff --git a/pypy/module/cpyext/test1/test_translate.py b/pypy/module/cpyext/test/test_translate.py rename from pypy/module/cpyext/test1/test_translate.py rename to pypy/module/cpyext/test/test_translate.py diff --git a/pypy/module/cpyext/test1/test_tupleobject.py b/pypy/module/cpyext/test/test_tupleobject.py rename from pypy/module/cpyext/test1/test_tupleobject.py rename to pypy/module/cpyext/test/test_tupleobject.py diff --git a/pypy/module/cpyext/test1/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py rename from pypy/module/cpyext/test1/test_typeobject.py rename to pypy/module/cpyext/test/test_typeobject.py diff --git a/pypy/module/cpyext/test1/test_unicodeobject.py b/pypy/module/cpyext/test/test_unicodeobject.py rename from pypy/module/cpyext/test1/test_unicodeobject.py rename to pypy/module/cpyext/test/test_unicodeobject.py diff --git a/pypy/module/cpyext/test1/test_userslots.py b/pypy/module/cpyext/test/test_userslots.py rename from pypy/module/cpyext/test1/test_userslots.py rename to pypy/module/cpyext/test/test_userslots.py diff --git a/pypy/module/cpyext/test1/test_version.py b/pypy/module/cpyext/test/test_version.py rename from pypy/module/cpyext/test1/test_version.py rename to pypy/module/cpyext/test/test_version.py diff --git a/pypy/module/cpyext/test1/test_weakref.py b/pypy/module/cpyext/test/test_weakref.py rename from pypy/module/cpyext/test1/test_weakref.py rename to pypy/module/cpyext/test/test_weakref.py diff --git a/pypy/module/cpyext/test0/__init__.py b/pypy/module/cpyext/test0/__init__.py deleted file mode 100644 diff --git a/pypy/module/cpyext/test0/conftest.py b/pypy/module/cpyext/test0/conftest.py deleted file mode 100644 --- a/pypy/module/cpyext/test0/conftest.py +++ /dev/null @@ -1,37 +0,0 @@ -import os -import pytest - -def pytest_configure(config): - if config.option.runappdirect: - import sys - import py - from pypy import pypydir - sys.path.append(str(py.path.local(pypydir) / 'tool' / 'cpyext')) - return - from pypy.tool.pytest.objspace import gettestobjspace - # For some reason (probably a ll2ctypes cache issue on linux64) - # it's necessary to run "import time" at least once before any - # other cpyext test, otherwise the same statement will fail in - # test_datetime.py. - space = gettestobjspace(usemodules=['time']) - space.getbuiltinmodule("time") - -def pytest_ignore_collect(path, config): - # ensure additional functions are registered - import pypy.module.cpyext.test.test_cpyext - return False - -def pytest_funcarg__api(request): - return request.cls.api - -if os.name == 'nt': - @pytest.yield_fixture(autouse=True, scope='session') - def prevent_dialog_box(): - """Do not open dreaded dialog box on segfault on Windows""" - import ctypes - SEM_NOGPFAULTERRORBOX = 0x0002 # From MSDN - old_err_mode = ctypes.windll.kernel32.GetErrorMode() - new_err_mode = old_err_mode | SEM_NOGPFAULTERRORBOX - ctypes.windll.kernel32.SetErrorMode(new_err_mode) - yield - ctypes.windll.kernel32.SetErrorMode(old_err_mode) diff --git a/pypy/module/cpyext/test1/__init__.py b/pypy/module/cpyext/test1/__init__.py deleted file mode 100644 diff --git a/pypy/module/cpyext/test1/conftest.py b/pypy/module/cpyext/test1/conftest.py deleted file mode 100644 --- a/pypy/module/cpyext/test1/conftest.py +++ /dev/null @@ -1,37 +0,0 @@ -import os -import pytest - -def pytest_configure(config): - if config.option.runappdirect: - import sys - import py - from pypy import pypydir - sys.path.append(str(py.path.local(pypydir) / 'tool' / 'cpyext')) - return - from pypy.tool.pytest.objspace import gettestobjspace - # For some reason (probably a ll2ctypes cache issue on linux64) - # it's necessary to run "import time" at least once before any - # other cpyext test, otherwise the same statement will fail in - # test_datetime.py. - space = gettestobjspace(usemodules=['time']) - space.getbuiltinmodule("time") - -def pytest_ignore_collect(path, config): - # ensure additional functions are registered - import pypy.module.cpyext.test.test_cpyext - return False - -def pytest_funcarg__api(request): - return request.cls.api - -if os.name == 'nt': - @pytest.yield_fixture(autouse=True, scope='session') - def prevent_dialog_box(): - """Do not open dreaded dialog box on segfault on Windows""" - import ctypes - SEM_NOGPFAULTERRORBOX = 0x0002 # From MSDN - old_err_mode = ctypes.windll.kernel32.GetErrorMode() - new_err_mode = old_err_mode | SEM_NOGPFAULTERRORBOX - ctypes.windll.kernel32.SetErrorMode(new_err_mode) - yield - ctypes.windll.kernel32.SetErrorMode(old_err_mode) diff --git a/pypy/module/select/__init__.py b/pypy/module/select/__init__.py --- a/pypy/module/select/__init__.py +++ b/pypy/module/select/__init__.py @@ -3,6 +3,7 @@ import sys import os +from rpython.rlib import _rsocket_rffi as _c class Module(MixedModule): @@ -31,6 +32,10 @@ for symbol in symbol_map: interpleveldefs[symbol] = "space.wrap(interp_kqueue.%s)" % symbol + if _c.PIPE_BUF is not None: + interpleveldefs['PIPE_BUF'] = 'space.wrap(%r)' % _c.PIPE_BUF + + def buildloaders(cls): from rpython.rlib import rpoll for name in rpoll.eventnames: diff --git a/pypy/module/select/test/test_select.py b/pypy/module/select/test/test_select.py --- a/pypy/module/select/test/test_select.py +++ b/pypy/module/select/test/test_select.py @@ -319,6 +319,11 @@ # ^^^ CPython gives 100, PyPy gives 1. I think both are OK as # long as there is no crash. + def test_PIPE_BUF(self): + # no PIPE_BUF on Windows; this test class is skipped on Windows. + import select + assert isinstance(select.PIPE_BUF, int) + class AppTestSelectWithSockets(_AppTestSelect): """Same tests with connected sockets. diff --git a/pypy/objspace/std/test/test_unicodeobject.py b/pypy/objspace/std/test/test_unicodeobject.py --- a/pypy/objspace/std/test/test_unicodeobject.py +++ b/pypy/objspace/std/test/test_unicodeobject.py @@ -397,14 +397,14 @@ assert str(123) == '123' assert str(object=123) == '123' assert str([2, 3]) == '[2, 3]' - assert str(errors='strict') == '' + #assert str(errors='strict') == '' --- obscure case, disabled for now class U(str): pass assert str(U()).__class__ is str assert U().__str__().__class__ is str assert U('test') == 'test' assert U('test').__class__ is U - assert U(errors='strict') == U('') + #assert U(errors='strict') == U('') --- obscure case, disabled for now def test_call_unicode_2(self): class X(object): @@ -1088,3 +1088,31 @@ assert u'A\u03a3\u0345'.lower() == u'a\u03c2\u0345' assert u'\u03a3\u0345 '.lower() == u'\u03c3\u0345 ' + def test_unicode_constructor_misc(self): + x = u'foo' + x += u'bar' + assert str(x) is x + # + class U(str): + def __str__(self): + return u'BOK' + u = U(x) + assert str(u) == u'BOK' + # + class U2(str): + pass + z = U2(u'foobaz') + assert type(str(z)) is str + assert str(z) == u'foobaz' + # + # two completely corner cases where we differ from CPython: + #assert unicode(encoding='supposedly_the_encoding') == u'' + #assert unicode(errors='supposedly_the_error') == u'' + e = raises(TypeError, str, u'', 'supposedly_the_encoding') + assert str(e.value) == 'decoding str is not supported' + e = raises(TypeError, str, u'', errors='supposedly_the_error') + assert str(e.value) == 'decoding str is not supported' + e = raises(TypeError, str, u, 'supposedly_the_encoding') + assert str(e.value) == 'decoding str is not supported' + e = raises(TypeError, str, z, 'supposedly_the_encoding') + assert str(e.value) == 'decoding str is not supported' diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py --- a/pypy/objspace/std/unicodeobject.py +++ b/pypy/objspace/std/unicodeobject.py @@ -224,15 +224,20 @@ def descr_new(space, w_unicodetype, w_object=None, w_encoding=None, w_errors=None): if w_object is None: - w_value = W_UnicodeObject.EMPTY + w_object = W_UnicodeObject.EMPTY + w_obj = w_object + + encoding, errors = _get_encoding_and_errors(space, w_encoding, + w_errors) + if encoding is None and errors is None: + # this is very quick if w_obj is already a w_unicode + w_value = unicode_from_object(space, w_obj) else: - encoding, errors = _get_encoding_and_errors(space, w_encoding, - w_errors) - if encoding is None and errors is None: - w_value = unicode_from_object(space, w_object) - else: - w_value = unicode_from_encoded_object(space, w_object, - encoding, errors) + if space.isinstance_w(w_obj, space.w_unicode): + raise oefmt(space.w_TypeError, + "decoding str is not supported") + w_value = unicode_from_encoded_object(space, w_obj, + encoding, errors) if space.is_w(w_unicodetype, space.w_unicode): return w_value diff --git a/pypy/testrunner_cfg.py b/pypy/testrunner_cfg.py --- a/pypy/testrunner_cfg.py +++ b/pypy/testrunner_cfg.py @@ -5,7 +5,7 @@ 'translator/c', 'rlib', 'memory/test', 'jit/metainterp', 'jit/backend/arm', 'jit/backend/x86', - 'jit/backend/zarch', + 'jit/backend/zarch', 'module/cpyext/test', ] def collect_one_testdir(testdirs, reldir, tests): diff --git a/rpython/doc/examples.rst b/rpython/doc/examples.rst --- a/rpython/doc/examples.rst +++ b/rpython/doc/examples.rst @@ -19,7 +19,7 @@ * Typhon, 'A virtual machine for Monte', in active development, https://github.com/monte-language/typhon * Tulip, an untyped functional language, in language design mode, maintained, - https://github.com/tulip-lang/tulip/ + https://github.com/tulip-lang/tulip/ * Pycket, a Racket implementation, proof of concept, small language core working, a lot of primitives are missing. Slow development https://github.com/samth/pycket diff --git a/rpython/rlib/_rsocket_rffi.py b/rpython/rlib/_rsocket_rffi.py --- a/rpython/rlib/_rsocket_rffi.py +++ b/rpython/rlib/_rsocket_rffi.py @@ -33,6 +33,7 @@ 'arpa/inet.h', 'stdint.h', 'errno.h', + 'limits.h', ) if _HAS_AF_PACKET: includes += ('netpacket/packet.h', @@ -113,6 +114,7 @@ F_GETFL = platform.DefinedConstantInteger('F_GETFL') F_SETFL = platform.DefinedConstantInteger('F_SETFL') FIONBIO = platform.DefinedConstantInteger('FIONBIO') + PIPE_BUF = platform.DefinedConstantInteger('PIPE_BUF') INVALID_SOCKET = platform.DefinedConstantInteger('INVALID_SOCKET') INET_ADDRSTRLEN = platform.DefinedConstantInteger('INET_ADDRSTRLEN') @@ -1085,6 +1087,7 @@ WSAEWOULDBLOCK = cConfig.WSAEWOULDBLOCK or cConfig.EWOULDBLOCK WSAEAFNOSUPPORT = cConfig.WSAEAFNOSUPPORT or cConfig.EAFNOSUPPORT EISCONN = cConfig.EISCONN or cConfig.WSAEISCONN +PIPE_BUF = cConfig.PIPE_BUF # may be None linux = cConfig.linux WIN32 = cConfig.WIN32 _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit