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

Side by Side Diff: Doc/library/socket.rst

Issue 28332: silent truncations in socket.htons and socket.ntohs
Patch Set: Created 3 years 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 | Lib/test/test_socket.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`socket` --- Low-level networking interface 1 :mod:`socket` --- Low-level networking interface
2 ================================================ 2 ================================================
3 3
4 .. module:: socket 4 .. module:: socket
5 :synopsis: Low-level networking interface. 5 :synopsis: Low-level networking interface.
6 6
7 **Source code:** :source:`Lib/socket.py` 7 **Source code:** :source:`Lib/socket.py`
8 8
9 -------------- 9 --------------
10 10
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 Convert 32-bit positive integers from network to host byte order. On machine s 656 Convert 32-bit positive integers from network to host byte order. On machine s
657 where the host byte order is the same as network byte order, this is a no-op; 657 where the host byte order is the same as network byte order, this is a no-op;
658 otherwise, it performs a 4-byte swap operation. 658 otherwise, it performs a 4-byte swap operation.
659 659
660 660
661 .. function:: ntohs(x) 661 .. function:: ntohs(x)
662 662
663 Convert 16-bit positive integers from network to host byte order. On machine s 663 Convert 16-bit positive integers from network to host byte order. On machine s
664 where the host byte order is the same as network byte order, this is a no-op; 664 where the host byte order is the same as network byte order, this is a no-op;
665 otherwise, it performs a 2-byte swap operation. 665 otherwise, it performs a 2-byte swap operation.
666
667 .. deprecated:: 3.7
668 In case *x* does not fit in 16-bit unsigned integer, but does fit in a
669 positive C int, it is silently truncated to 16-bit unsigned integer.
670 This silent truncation feature is deprecated, and will raise an
671 exception in future versions of Python.
666 672
667 673
668 .. function:: htonl(x) 674 .. function:: htonl(x)
669 675
670 Convert 32-bit positive integers from host to network byte order. On machine s 676 Convert 32-bit positive integers from host to network byte order. On machine s
671 where the host byte order is the same as network byte order, this is a no-op; 677 where the host byte order is the same as network byte order, this is a no-op;
672 otherwise, it performs a 4-byte swap operation. 678 otherwise, it performs a 4-byte swap operation.
673 679
674 680
675 .. function:: htons(x) 681 .. function:: htons(x)
676 682
677 Convert 16-bit positive integers from host to network byte order. On machine s 683 Convert 16-bit positive integers from host to network byte order. On machine s
678 where the host byte order is the same as network byte order, this is a no-op; 684 where the host byte order is the same as network byte order, this is a no-op;
679 otherwise, it performs a 2-byte swap operation. 685 otherwise, it performs a 2-byte swap operation.
686
687 .. deprecated:: 3.7
688 In case *x* does not fit in 16-bit unsigned integer, but does fit in a
689 positive C int, it is silently truncated to 16-bit unsigned integer.
690 This silent truncation feature is deprecated, and will raise an
691 exception in future versions of Python.
680 692
681 693
682 .. function:: inet_aton(ip_string) 694 .. function:: inet_aton(ip_string)
683 695
684 Convert an IPv4 address from dotted-quad string format (for example, 696 Convert an IPv4 address from dotted-quad string format (for example,
685 '123.45.67.89') to 32-bit packed binary format, as a bytes object four charac ters in 697 '123.45.67.89') to 32-bit packed binary format, as a bytes object four charac ters in
686 length. This is useful when conversing with a program that uses the standard C 698 length. This is useful when conversing with a program that uses the standard C
687 library and needs objects of type :c:type:`struct in_addr`, which is the C ty pe 699 library and needs objects of type :c:type:`struct in_addr`, which is the C ty pe
688 for the 32-bit packed binary this function returns. 700 for the 32-bit packed binary this function returns.
689 701
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 1735
1724 - *An Advanced 4.3BSD Interprocess Communication Tutorial*, by Samuel J. Lef fler et 1736 - *An Advanced 4.3BSD Interprocess Communication Tutorial*, by Samuel J. Lef fler et
1725 al, 1737 al,
1726 1738
1727 both in the UNIX Programmer's Manual, Supplementary Documents 1 (sections 1739 both in the UNIX Programmer's Manual, Supplementary Documents 1 (sections
1728 PS1:7 and PS1:8). The platform-specific reference material for the various 1740 PS1:7 and PS1:8). The platform-specific reference material for the various
1729 socket-related system calls are also a valuable source of information on the 1741 socket-related system calls are also a valuable source of information on the
1730 details of socket semantics. For Unix, refer to the manual pages; for Window s, 1742 details of socket semantics. For Unix, refer to the manual pages; for Window s,
1731 see the WinSock (or Winsock 2) specification. For IPv6-ready APIs, readers m ay 1743 see the WinSock (or Winsock 2) specification. For IPv6-ready APIs, readers m ay
1732 want to refer to :rfc:`3493` titled Basic Socket Interface Extensions for IPv 6. 1744 want to refer to :rfc:`3493` titled Basic Socket Interface Extensions for IPv 6.
OLDNEW
« no previous file with comments | « no previous file | Lib/test/test_socket.py » ('j') | no next file with comments »

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