Commits

Manuel Jacob  committed f79af72 Merge

hg merge py3k

  • Participants
  • Parent commits 18dcd07, 27567bc
  • Branches py3k

Comments (0)

Files changed (8)

File pypy/module/_io/interp_bufferedio.py

             raise operationerrfmt(space.w_ValueError,
                 "whence must be between 0 and 2, not %d", whence)
         self._check_closed(space, "seek of closed file")
+        check_seekable_w(space, self.w_raw)
         if whence != 2 and self.readable:
             # Check if seeking leaves us inside the current buffer, so as to
             # return quickly if possible. Also, we needn't take the lock in

File pypy/module/_io/test/test_bufferedio.py

                 raise _io.UnsupportedOperation("not seekable")
             def tell(self, *args):
                 raise _io.UnsupportedOperation("not seekable")
-        bufio = _io.BufferedReader(Unseekable())
+        bufio = _io.BufferedReader(Unseekable(b"A" * 10))
         raises(_io.UnsupportedOperation, bufio.tell)
         raises(_io.UnsupportedOperation, bufio.seek, 0)
+        bufio.read(1)
+        raises(_io.UnsupportedOperation, bufio.seek, 0)
+        raises(_io.UnsupportedOperation, bufio.tell)
 
 class AppTestBufferedReaderWithThreads(AppTestBufferedReader):
     spaceconfig = dict(usemodules=['_io', 'thread'])

File pypy/module/_socket/interp_func.py

 from pypy.interpreter.gateway import unwrap_spec, WrappedDefault
 from pypy.module._socket.interp_socket import (
-    converted_error, W_RSocket, addr_as_object, ipaddr_from_object, get_error)
+    converted_error, W_RSocket, addr_as_object, fill_from_object, get_error)
 from rpython.rlib import rsocket
 from rpython.rlib.rsocket import SocketError, INVALID_SOCKET
 from pypy.interpreter.error import OperationError
 
     Get host and port for a sockaddr."""
     try:
-        w_host, w_port = space.fixedview(w_sockaddr, 2)
-        host = space.str_w(w_host)
-        port = str(space.int_w(w_port))
+        host = space.str_w((space.getitem(w_sockaddr, space.wrap(0))))
+        port = str(space.int_w(space.getitem(w_sockaddr, space.wrap(1))))
         lst = rsocket.getaddrinfo(host, port, rsocket.AF_UNSPEC,
                                   rsocket.SOCK_DGRAM, 0,
                                   rsocket.AI_NUMERICHOST)
                 get_error(space, 'error'),
                 space.wrap("sockaddr resolved to multiple addresses"))
         addr = lst[0][4]
+        fill_from_object(addr, space, w_sockaddr)
         host, servport = rsocket.getnameinfo(addr, flags)
     except SocketError, e:
         raise converted_error(space, e)

File pypy/module/_socket/interp_socket.py

 
     def destructor(self):
         assert isinstance(self, W_RSocket)
-        RSocket.__del__(self)
+        if self.fd != rsocket.INVALID_SOCKET:
+            try:
+                self._dealloc_warn()
+            finally:
+                self.close_w(self.space)
 
     def _dealloc_warn(self):
         space = self.space
-        if not space:
-            return
         try:
             msg = (u"unclosed %s" %
                    space.unicode_w(space.repr(space.wrap(self))))

File pypy/module/_socket/test/test_sock_app.py

     space.raises_w(get_error(space, 'error'), space.appexec,
                    [w_socket, sockaddr, space.wrap(0)],
                    "(_socket, sockaddr, flags): return _socket.getnameinfo(sockaddr, flags)")
-
+    if socket.has_ipv6:
+        sockaddr = space.newtuple([space.wrap('::1'), space.wrap(0),
+                                   space.wrap(0xffffffff)])
+        space.raises_w(space.w_OverflowError, space.appexec,
+                       [w_socket, sockaddr, space.wrap(0)],
+                       "(_socket, sockaddr, flags): return _socket.getnameinfo(sockaddr, flags)")
 
 def test_timeout():
     space.appexec([w_socket, space.wrap(25.4)],

File pypy/objspace/std/newformat.py

                 add_pct = False
             if self._precision == -1:
                 self._precision = default_precision
+            elif tp == "r":
+                tp = "g"
             result, special = rfloat.double_to_string(value, tp,
                                                       self._precision, flags)
             if add_pct:

File pypy/objspace/std/test/test_floatobject.py

     def test_format(self):
         f = 1.1234e200
         assert f.__format__("G") == "1.1234E+200"
+        assert 123.456.__format__('.4') == '123.5'
+        assert 1234.56.__format__('.4') == '1.235e+03'
+        assert 12345.6.__format__('.4') == '1.235e+04'
 
     def test_float_real(self):
         class A(float): pass

File rpython/rlib/rsocket.py

     def __del__(self):
         fd = self.fd
         if fd != _c.INVALID_SOCKET:
-            try:
-                self._dealloc_warn()
-            finally:
-                self.fd = _c.INVALID_SOCKET
-                _c.socketclose(fd)
-
-    def _dealloc_warn(self):
-        """Called when implicitly closed via the deconstructor"""
-        pass
+            self.fd = _c.INVALID_SOCKET
+            _c.socketclose(fd)
 
     if hasattr(_c, 'fcntl'):
         def _setblocking(self, block):