Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Side by Side Diff: Lib/socket.py

Issue 20689: socket.AddressFamily is absent in html pydoc
Patch Set: Created 5 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Wrapper module for _socket, providing some additional facilities 1 # Wrapper module for _socket, providing some additional facilities
2 # implemented in Python. 2 # implemented in Python.
3 3
4 """\ 4 """\
5 This module provides socket operations and some related functions. 5 This module provides socket operations and some related functions.
6 On Unix, it supports IP (Internet Protocol) and Unix domain sockets. 6 On Unix, it supports IP (Internet Protocol) and Unix domain sockets.
7 On other systems, it only supports IP. Functions specific for a 7 On other systems, it only supports IP. Functions specific for a
8 socket are available as methods of the socket object. 8 socket are available as methods of the socket object.
9 9
10 Functions: 10 Functions:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 from enum import IntEnum 51 from enum import IntEnum
52 52
53 try: 53 try:
54 import errno 54 import errno
55 except ImportError: 55 except ImportError:
56 errno = None 56 errno = None
57 EBADF = getattr(errno, 'EBADF', 9) 57 EBADF = getattr(errno, 'EBADF', 9)
58 EAGAIN = getattr(errno, 'EAGAIN', 11) 58 EAGAIN = getattr(errno, 'EAGAIN', 11)
59 EWOULDBLOCK = getattr(errno, 'EWOULDBLOCK', 11) 59 EWOULDBLOCK = getattr(errno, 'EWOULDBLOCK', 11)
60 60
61 __all__ = ["getfqdn", "create_connection"] 61 __all__ = ["fromfd", "getfqdn", "create_connection",
62 "AddressFamily", "SocketType",
63 ]
62 __all__.extend(os._get_exports_list(_socket)) 64 __all__.extend(os._get_exports_list(_socket))
63 65
64 # Set up the socket.AF_* socket.SOCK_* constants as members of IntEnums for 66 # Set up the socket.AF_* socket.SOCK_* constants as members of IntEnums for
65 # nicer string representations. 67 # nicer string representations.
66 # Note that _socket only knows about the integer values. The public interface 68 # Note that _socket only knows about the integer values. The public interface
67 # in this module understands the enums and translates them back from integers 69 # in this module understands the enums and translates them back from integers
68 # where needed (e.g. .family property of a socket object). 70 # where needed (e.g. .family property of a socket object).
69 AddressFamily = IntEnum('AddressFamily', 71 AddressFamily = IntEnum('AddressFamily',
70 {name: value for name, value in globals().items() 72 {name: value for name, value in globals().items()
71 if name.isupper() and name.startswith('AF_')}) 73 if name.isupper() and name.startswith('AF_')})
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 return socket(family, type, proto, nfd) 296 return socket(family, type, proto, nfd)
295 297
296 if hasattr(_socket.socket, "share"): 298 if hasattr(_socket.socket, "share"):
297 def fromshare(info): 299 def fromshare(info):
298 """ fromshare(info) -> socket object 300 """ fromshare(info) -> socket object
299 301
300 Create a socket object from a the bytes object returned by 302 Create a socket object from a the bytes object returned by
301 socket.share(pid). 303 socket.share(pid).
302 """ 304 """
303 return socket(0, 0, 0, info) 305 return socket(0, 0, 0, info)
306 __all__.append("fromshare")
304 307
305 if hasattr(_socket, "socketpair"): 308 if hasattr(_socket, "socketpair"):
306 309
307 def socketpair(family=None, type=SOCK_STREAM, proto=0): 310 def socketpair(family=None, type=SOCK_STREAM, proto=0):
308 """socketpair([family[, type[, proto]]]) -> (socket object, socket objec t) 311 """socketpair([family[, type[, proto]]]) -> (socket object, socket objec t)
309 312
310 Create a pair of socket objects from the sockets returned by the platfor m 313 Create a pair of socket objects from the sockets returned by the platfor m
311 socketpair() function. 314 socketpair() function.
312 The arguments are the same as for socket() except the default family is 315 The arguments are the same as for socket() except the default family is
313 AF_UNIX if defined on the platform; otherwise, the default is AF_INET. 316 AF_UNIX if defined on the platform; otherwise, the default is AF_INET.
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 """ 529 """
527 # We override this function since we want to translate the numeric family 530 # We override this function since we want to translate the numeric family
528 # and socket type values to enum constants. 531 # and socket type values to enum constants.
529 addrlist = [] 532 addrlist = []
530 for res in _socket.getaddrinfo(host, port, family, type, proto, flags): 533 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
531 af, socktype, proto, canonname, sa = res 534 af, socktype, proto, canonname, sa = res
532 addrlist.append((_intenum_converter(af, AddressFamily), 535 addrlist.append((_intenum_converter(af, AddressFamily),
533 _intenum_converter(socktype, SocketType), 536 _intenum_converter(socktype, SocketType),
534 proto, canonname, sa)) 537 proto, canonname, sa))
535 return addrlist 538 return addrlist
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+