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

Delta Between Two Patch Sets: Doc/library/socket.rst

Issue 28332: silent truncations in socket.htons and socket.ntohs
Left Patch Set: Created 2 years, 7 months ago
Right Patch Set: Created 2 years, 7 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | Lib/test/test_socket.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 666
667 Note that in case *x* does not fit in 16-bit unsigned integer, but does fit 667 .. deprecated:: 3.7
storchaka 2016/10/01 21:37:42 Maybe use the "deprecated" directive?
668 in a positive C int, it is silently truncated to 16-bit unsigned integer. 668 In case *x* does not fit in 16-bit unsigned integer, but does fit in a
669 However, this silent truncation feature is deprecated, and will raise an 669 positive C int, it is silently truncated to 16-bit unsigned integer.
670 exception in future versions of Python. 670 This silent truncation feature is deprecated, and will raise an
671 exception in future versions of Python.
671 672
672 673
673 .. function:: htonl(x) 674 .. function:: htonl(x)
674 675
675 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
676 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;
677 otherwise, it performs a 4-byte swap operation. 678 otherwise, it performs a 4-byte swap operation.
678 679
679 680
680 .. function:: htons(x) 681 .. function:: htons(x)
681 682
682 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
683 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;
684 otherwise, it performs a 2-byte swap operation. 685 otherwise, it performs a 2-byte swap operation.
685 686
686 Note that in case *x* does not fit in 16-bit unsigned integer, but does fit 687 .. deprecated:: 3.7
687 in a positive C int, it is silently truncated to 16-bit unsigned integer. 688 In case *x* does not fit in 16-bit unsigned integer, but does fit in a
688 However, this silent truncation feature is deprecated, and will raise an 689 positive C int, it is silently truncated to 16-bit unsigned integer.
689 exception in future versions of Python. 690 This silent truncation feature is deprecated, and will raise an
691 exception in future versions of Python.
690 692
691 693
692 .. function:: inet_aton(ip_string) 694 .. function:: inet_aton(ip_string)
693 695
694 Convert an IPv4 address from dotted-quad string format (for example, 696 Convert an IPv4 address from dotted-quad string format (for example,
695 '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
696 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
697 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
698 for the 32-bit packed binary this function returns. 700 for the 32-bit packed binary this function returns.
699 701
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 1735
1734 - *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
1735 al, 1737 al,
1736 1738
1737 both in the UNIX Programmer's Manual, Supplementary Documents 1 (sections 1739 both in the UNIX Programmer's Manual, Supplementary Documents 1 (sections
1738 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
1739 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
1740 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,
1741 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
1742 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.
LEFTRIGHT

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