Author: Manuel Jacob Branch: py3k Changeset: r61521:f79af72713a4 Date: 2013-02-21 01:22 +0100 http://bitbucket.org/pypy/pypy/changeset/f79af72713a4/
Log: hg merge py3k diff --git a/pypy/module/_io/interp_bufferedio.py b/pypy/module/_io/interp_bufferedio.py --- a/pypy/module/_io/interp_bufferedio.py +++ b/pypy/module/_io/interp_bufferedio.py @@ -266,6 +266,7 @@ 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 diff --git a/pypy/module/_io/test/test_bufferedio.py b/pypy/module/_io/test/test_bufferedio.py --- a/pypy/module/_io/test/test_bufferedio.py +++ b/pypy/module/_io/test/test_bufferedio.py @@ -223,9 +223,12 @@ 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']) diff --git a/pypy/module/_socket/interp_func.py b/pypy/module/_socket/interp_func.py --- a/pypy/module/_socket/interp_func.py +++ b/pypy/module/_socket/interp_func.py @@ -1,6 +1,6 @@ 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 @@ -121,9 +121,8 @@ 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) @@ -132,6 +131,7 @@ 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) 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 @@ -166,12 +166,14 @@ 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)))) diff --git a/pypy/module/_socket/test/test_sock_app.py b/pypy/module/_socket/test/test_sock_app.py --- a/pypy/module/_socket/test/test_sock_app.py +++ b/pypy/module/_socket/test/test_sock_app.py @@ -273,7 +273,12 @@ 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)], diff --git a/pypy/objspace/std/newformat.py b/pypy/objspace/std/newformat.py --- a/pypy/objspace/std/newformat.py +++ b/pypy/objspace/std/newformat.py @@ -949,6 +949,8 @@ 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: diff --git a/pypy/objspace/std/test/test_floatobject.py b/pypy/objspace/std/test/test_floatobject.py --- a/pypy/objspace/std/test/test_floatobject.py +++ b/pypy/objspace/std/test/test_floatobject.py @@ -444,6 +444,9 @@ 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 diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py --- a/rpython/rlib/rsocket.py +++ b/rpython/rlib/rsocket.py @@ -497,15 +497,8 @@ 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): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit