Author: Richard Plangger <planri...@gmail.com>
Branch: ppc-vsx-support
Changeset: r88096:5083544e46fd
Date: 2016-11-03 09:34 +0100
http://bitbucket.org/pypy/pypy/changeset/5083544e46fd/

Log:    merge default

diff --git a/pypy/doc/release-pypy2.7-v5.6.0.rst 
b/pypy/doc/release-pypy2.7-v5.6.0.rst
--- a/pypy/doc/release-pypy2.7-v5.6.0.rst
+++ b/pypy/doc/release-pypy2.7-v5.6.0.rst
@@ -16,7 +16,7 @@
 We changed ``timeit`` to now report average +- standard deviation, which is
 better than the misleading minimum value reported in CPython.
 
-We now support building PyPy with OpenSSL 1.1 in our built-in _sll module, as
+We now support building PyPy with OpenSSL 1.1 in our built-in _ssl module, as
 well as maintaining support for previous versions.
 
 XXX
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
@@ -81,6 +81,14 @@
 Improve support for new buffer interface in cpyext, bf_getbuffer on built-in
 types still missing
 
+
+.. branch: fix-struct-unpack-Q
+
+Improve compatibility with CPython in the ``struct`` module. In particular,
+``struct.unpack`` now returns an ``int`` whenever the returned value fits,
+while previously it always returned a ``long`` for certains format codes such
+as ``Q`` (and also ``I``, ``L`` and ``q`` on 32 bit)
+
 .. branch: zarch-simd-support
 
 s390x implementation for vector operations used in VecOpt
diff --git a/pypy/module/__builtin__/test/test_builtin.py 
b/pypy/module/__builtin__/test/test_builtin.py
--- a/pypy/module/__builtin__/test/test_builtin.py
+++ b/pypy/module/__builtin__/test/test_builtin.py
@@ -509,59 +509,6 @@
         assert eval("i", None, None) == 4
         assert eval('a', None, dict(a=42)) == 42
 
-    def test_compile(self):
-        co = compile('1+2', '?', 'eval')
-        assert eval(co) == 3
-        co = compile(buffer('1+2'), '?', 'eval')
-        assert eval(co) == 3
-        exc = raises(TypeError, compile, chr(0), '?', 'eval')
-        assert str(exc.value) == "compile() expected string without null bytes"
-        exc = raises(TypeError, compile, unichr(0), '?', 'eval')
-        assert str(exc.value) == "compile() expected string without null bytes"
-        exc = raises(TypeError, compile, memoryview('1+2'), '?', 'eval')
-        assert str(exc.value) == "expected a readable buffer object"
-        compile("from __future__ import with_statement", "<test>", "exec")
-        raises(SyntaxError, compile, '-', '?', 'eval')
-        raises(ValueError, compile, '"\\xt"', '?', 'eval')
-        raises(ValueError, compile, '1+2', '?', 'maybenot')
-        raises(ValueError, compile, "\n", "<string>", "exec", 0xff)
-        raises(TypeError, compile, '1+2', 12, 34)
-
-    def test_compile_error_message(self):
-        import re
-        compile('# -*- coding: iso-8859-15 -*-\n', 'dummy', 'exec')
-        compile(b'\xef\xbb\xbf\n', 'dummy', 'exec')
-        compile(b'\xef\xbb\xbf# -*- coding: utf-8 -*-\n', 'dummy', 'exec')
-        exc = raises(SyntaxError, compile,
-            b'# -*- coding: fake -*-\n', 'dummy', 'exec')
-        assert 'fake' in str(exc.value)
-        exc = raises(SyntaxError, compile,
-            b'\xef\xbb\xbf# -*- coding: iso-8859-15 -*-\n', 'dummy', 'exec')
-        assert 'iso-8859-15' in str(exc.value)
-        assert 'BOM' in str(exc.value)
-        exc = raises(SyntaxError, compile,
-            b'\xef\xbb\xbf# -*- coding: fake -*-\n', 'dummy', 'exec')
-        assert 'fake' in str(exc.value)
-        assert 'BOM' in str(exc.value)
-
-    def test_unicode_compile(self):
-        try:
-            compile(u'-', '?', 'eval')
-        except SyntaxError as e:
-            assert e.lineno == 1
-
-    def test_unicode_encoding_compile(self):
-        code = u"# -*- coding: utf-8 -*-\npass\n"
-        raises(SyntaxError, compile, code, "tmp", "exec")
-
-    def test_recompile_ast(self):
-        import _ast
-        # raise exception when node type doesn't match with compile mode
-        co1 = compile('print 1', '<string>', 'exec', _ast.PyCF_ONLY_AST)
-        raises(TypeError, compile, co1, '<ast>', 'eval')
-        co2 = compile('1+1', '<string>', 'eval', _ast.PyCF_ONLY_AST)
-        compile(co2, '<ast>', 'eval')
-
     def test_isinstance(self):
         assert isinstance(5, int)
         assert isinstance(5, object)
@@ -624,34 +571,10 @@
         raises(TypeError, hasattr, x, 42)
         raises(UnicodeError, hasattr, x, u'\u5678')  # cannot encode attr name
 
-    def test_compile_leading_newlines(self):
-        src = """
-def fn(): pass
-"""
-        co = compile(src, 'mymod', 'exec')
-        firstlineno = co.co_firstlineno
-        assert firstlineno == 2
-
-    def test_compile_null_bytes(self):
-        raises(TypeError, compile, '\x00', 'mymod', 'exec', 0)
-        src = "#abc\x00def\n"
-        raises(TypeError, compile, src, 'mymod', 'exec')
-        raises(TypeError, compile, src, 'mymod', 'exec', 0)
+    def test_execfile_args(self):
         execfile(self.nullbytes) # works
-
-    def test_execfile_args(self):
         raises(TypeError, execfile, self.nonexistent, {}, ())
 
-    def test_compile_null_bytes_flag(self):
-        try:
-            from _ast import PyCF_ACCEPT_NULL_BYTES
-        except ImportError:
-            skip('PyPy only (requires _ast.PyCF_ACCEPT_NULL_BYTES)')
-        raises(SyntaxError, compile, '\x00', 'mymod', 'exec',
-               PyCF_ACCEPT_NULL_BYTES)
-        src = "#abc\x00def\n"
-        compile(src, 'mymod', 'exec', PyCF_ACCEPT_NULL_BYTES)  # works
-
     def test_print_function(self):
         import __builtin__
         import sys
diff --git a/pypy/module/__builtin__/test/test_compile.py 
b/pypy/module/__builtin__/test/test_compile.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/__builtin__/test/test_compile.py
@@ -0,0 +1,77 @@
+class AppTestCompile:
+    def test_simple(self):
+        co = compile('1+2', '?', 'eval')
+        assert eval(co) == 3
+        co = compile(buffer('1+2'), '?', 'eval')
+        assert eval(co) == 3
+        exc = raises(TypeError, compile, chr(0), '?', 'eval')
+        assert str(exc.value) == "compile() expected string without null bytes"
+        exc = raises(TypeError, compile, unichr(0), '?', 'eval')
+        assert str(exc.value) == "compile() expected string without null bytes"
+        exc = raises(TypeError, compile, memoryview('1+2'), '?', 'eval')
+        assert str(exc.value) == "expected a readable buffer object"
+        compile("from __future__ import with_statement", "<test>", "exec")
+        raises(SyntaxError, compile, '-', '?', 'eval')
+        raises(ValueError, compile, '"\\xt"', '?', 'eval')
+        raises(ValueError, compile, '1+2', '?', 'maybenot')
+        raises(ValueError, compile, "\n", "<string>", "exec", 0xff)
+        raises(TypeError, compile, '1+2', 12, 34)
+
+    def test_error_message(self):
+        import re
+        compile('# -*- coding: iso-8859-15 -*-\n', 'dummy', 'exec')
+        compile(b'\xef\xbb\xbf\n', 'dummy', 'exec')
+        compile(b'\xef\xbb\xbf# -*- coding: utf-8 -*-\n', 'dummy', 'exec')
+        exc = raises(SyntaxError, compile,
+            b'# -*- coding: fake -*-\n', 'dummy', 'exec')
+        assert 'fake' in str(exc.value)
+        exc = raises(SyntaxError, compile,
+            b'\xef\xbb\xbf# -*- coding: iso-8859-15 -*-\n', 'dummy', 'exec')
+        assert 'iso-8859-15' in str(exc.value)
+        assert 'BOM' in str(exc.value)
+        exc = raises(SyntaxError, compile,
+            b'\xef\xbb\xbf# -*- coding: fake -*-\n', 'dummy', 'exec')
+        assert 'fake' in str(exc.value)
+        assert 'BOM' in str(exc.value)
+
+    def test_unicode(self):
+        try:
+            compile(u'-', '?', 'eval')
+        except SyntaxError as e:
+            assert e.lineno == 1
+
+    def test_unicode_encoding(self):
+        code = u"# -*- coding: utf-8 -*-\npass\n"
+        raises(SyntaxError, compile, code, "tmp", "exec")
+
+    def test_recompile_ast(self):
+        import _ast
+        # raise exception when node type doesn't match with compile mode
+        co1 = compile('print 1', '<string>', 'exec', _ast.PyCF_ONLY_AST)
+        raises(TypeError, compile, co1, '<ast>', 'eval')
+        co2 = compile('1+1', '<string>', 'eval', _ast.PyCF_ONLY_AST)
+        compile(co2, '<ast>', 'eval')
+
+    def test_leading_newlines(self):
+        src = """
+def fn(): pass
+"""
+        co = compile(src, 'mymod', 'exec')
+        firstlineno = co.co_firstlineno
+        assert firstlineno == 2
+
+    def test_null_bytes(self):
+        raises(TypeError, compile, '\x00', 'mymod', 'exec', 0)
+        src = "#abc\x00def\n"
+        raises(TypeError, compile, src, 'mymod', 'exec')
+        raises(TypeError, compile, src, 'mymod', 'exec', 0)
+
+    def test_null_bytes_flag(self):
+        try:
+            from _ast import PyCF_ACCEPT_NULL_BYTES
+        except ImportError:
+            skip('PyPy only (requires _ast.PyCF_ACCEPT_NULL_BYTES)')
+        raises(SyntaxError, compile, '\x00', 'mymod', 'exec',
+               PyCF_ACCEPT_NULL_BYTES)
+        src = "#abc\x00def\n"
+        compile(src, 'mymod', 'exec', PyCF_ACCEPT_NULL_BYTES)  # works
diff --git a/pypy/module/_socket/interp_socket.py 
b/pypy/module/_socket/interp_socket.py
--- a/pypy/module/_socket/interp_socket.py
+++ b/pypy/module/_socket/interp_socket.py
@@ -479,6 +479,14 @@
 
     @unwrap_spec(nbytes=int, flags=int)
     def recv_into_w(self, space, w_buffer, nbytes=0, flags=0):
+        """recv_into(buffer, [nbytes[, flags]]) -> nbytes_read
+
+        A version of recv() that stores its data into a buffer rather than 
creating
+        a new string.  Receive up to buffersize bytes from the socket.  If 
buffersize
+        is not specified (or 0), receive up to the size available in the given 
buffer.
+
+        See recv() for documentation about the flags.
+        """
         rwbuffer = space.getarg_w('w*', w_buffer)
         lgt = rwbuffer.getlength()
         if nbytes == 0 or nbytes > lgt:
@@ -490,6 +498,10 @@
 
     @unwrap_spec(nbytes=int, flags=int)
     def recvfrom_into_w(self, space, w_buffer, nbytes=0, flags=0):
+        """recvfrom_into(buffer[, nbytes[, flags]]) -> (nbytes, address info)
+
+        Like recv_into(buffer[, nbytes[, flags]]) but also return the sender's 
address info.
+        """
         rwbuffer = space.getarg_w('w*', w_buffer)
         lgt = rwbuffer.getlength()
         if nbytes == 0:
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -1362,8 +1362,14 @@
 def _time_to_timeval(t, l_timeval):
     import math
     fracpart, intpart = math.modf(t)
-    rffi.setintfield(l_timeval, 'c_tv_sec', int(intpart))
-    rffi.setintfield(l_timeval, 'c_tv_usec', int(fracpart * 1e6))
+    intpart = int(intpart)
+    fracpart = int(fracpart * 1e6)
+    if fracpart < 0:
+        intpart -= 1
+        fracpart += 1000000
+    assert 0 <= fracpart < 1000000
+    rffi.setintfield(l_timeval, 'c_tv_sec', intpart)
+    rffi.setintfield(l_timeval, 'c_tv_usec', fracpart)
 
 if not _WIN32:
     TMSP = lltype.Ptr(TMS)
diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -59,6 +59,17 @@
         compile(f, (str, float))(str(fname), t1)
         assert t1 == os.stat(str(fname)).st_mtime
 
+    def test_utime_negative_fraction(self):
+        def f(fname, t1):
+            os.utime(fname, (t1, t1))
+
+        fname = udir.join('test_utime_negative_fraction.txt')
+        fname.ensure()
+        t1 = -123.75
+        compile(f, (str, float))(str(fname), t1)
+        got = os.stat(str(fname)).st_mtime
+        assert got == -123 or got == -123.75
+
     @win_only
     def test__getfullpathname(self):
         posix = __import__(os.name)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to