[Python-Dev] Now test_socket fails
Guido van Rossum
guido@python.org
Wed, 31 Jul 2002 13:40:34 -0400
> What's socket.socket() supposed to do without any arguments? Can't work on
> Windows, because socket.py has
>
> if (sys.platform.lower().startswith("win")
> or (hasattr(os, 'uname') and os.uname()[0] == "BeOS")
> or sys.platform=="riscos"):
>
> _realsocketcall = _socket.socket
>
> def socket(family, type, proto=0):
> return _socketobject(_realsocketcall(family, type, proto))
Oops. It's supposed to default to AF_INET, SOCK_STREAM now. Can you
test this patch and check it in if it works?
*** socket.py 18 Jul 2002 17:08:34 -0000 1.22
--- socket.py 31 Jul 2002 17:35:25 -0000
***************
*** 62,68 ****
_realsocketcall = _socket.socket
! def socket(family, type, proto=0):
return _socketobject(_realsocketcall(family, type, proto))
if SSL_EXISTS:
--- 62,68 ----
_realsocketcall = _socket.socket
! def socket(family=AF_INET, type=SOCK_STREAM, proto=0):
return _socketobject(_realsocketcall(family, type, proto))
if SSL_EXISTS:
(There's another change we should really make -- instead of a socket
function, there should be a class socket whose constructor does the
work. That's necessary so that isinstance(s, socket.socket) works on
Windows; this currently works on Unix but not on Windows. But I don't
have time for that now; the above patch should do what you need.)
--Guido van Rossum (home page: http://www.python.org/~guido/)