@@ -46,17 +46,20 @@ created. Socket addresses are represented as follows:
4646- The address of an :const: `AF_UNIX ` socket bound to a file system node
4747 is represented as a string, using the file system encoding and the
4848 ``'surrogateescape' `` error handler (see :pep: `383 `). An address in
49- Linux's abstract namespace is returned as a :class : `bytes ` object with
49+ Linux's abstract namespace is returned as a :term : `bytes-like object ` with
5050 an initial null byte; note that sockets in this namespace can
5151 communicate with normal file system sockets, so programs intended to
5252 run on Linux may need to deal with both types of address. A string or
53- :class: ` bytes ` object can be used for either type of address when
53+ bytes-like object can be used for either type of address when
5454 passing it as an argument.
5555
5656 .. versionchanged :: 3.3
5757 Previously, :const: `AF_UNIX ` socket paths were assumed to use UTF-8
5858 encoding.
5959
60+ .. versionchanged: 3.5
61+ Writable :term:`bytes-like object` is now accepted.
62+
6063 - A pair ``(host, port) `` is used for the :const: `AF_INET ` address family,
6164 where *host * is a string representing either a hostname in Internet domain
6265 notation like ``'daring.cwi.nl' `` or an IPv4 address like ``'100.50.200.5' ``,
@@ -609,8 +612,8 @@ The :mod:`socket` module also offers various network-related services:
609612
610613.. function :: inet_ntoa(packed_ip)
611614
612- Convert a 32-bit packed IPv4 address (a bytes object four characters in
613- length) to its standard dotted-quad string representation (for example,
615+ Convert a 32-bit packed IPv4 address (a :term: ` bytes-like object ` four
616+ bytes in length) to its standard dotted-quad string representation (for example,
614617 '123.45.67.89'). This is useful when conversing with a program that uses the
615618 standard C library and needs objects of type :c:type: `struct in_addr `, which
616619 is the C type for the 32-bit packed binary data this function takes as an
@@ -621,6 +624,9 @@ The :mod:`socket` module also offers various network-related services:
621624 support IPv6, and :func: `inet_ntop ` should be used instead for IPv4/v6 dual
622625 stack support.
623626
627+ .. versionchanged: 3.5
628+ Writable :term:`bytes-like object` is now accepted.
629+
624630
625631 .. function :: inet_pton(address_family, ip_string)
626632
@@ -643,22 +649,26 @@ The :mod:`socket` module also offers various network-related services:
643649
644650.. function :: inet_ntop(address_family, packed_ip)
645651
646- Convert a packed IP address (a bytes object of some number of characters) to its
647- standard, family-specific string representation (for example, ``'7.10.0.5' `` or
648- ``'5aef:2b::8' ``). :func: `inet_ntop ` is useful when a library or network protocol
649- returns an object of type :c:type: `struct in_addr ` (similar to :func: `inet_ntoa `)
650- or :c:type: `struct in6_addr `.
652+ Convert a packed IP address (a :term: `bytes-like object ` of some number of
653+ bytes) to its standard, family-specific string representation (for
654+ example, ``'7.10.0.5' `` or ``'5aef:2b::8' ``).
655+ :func: `inet_ntop ` is useful when a library or network protocol returns an
656+ object of type :c:type: `struct in_addr ` (similar to :func: `inet_ntoa `) or
657+ :c:type: `struct in6_addr `.
651658
652659 Supported values for *address_family * are currently :const: `AF_INET ` and
653- :const: `AF_INET6 `. If the string *packed_ip * is not the correct length for the
654- specified address family, :exc: `ValueError ` will be raised. A
655- :exc: `OSError ` is raised for errors from the call to :func: `inet_ntop `.
660+ :const: `AF_INET6 `. If the bytes object *packed_ip * is not the correct
661+ length for the specified address family, :exc: `ValueError ` will be raised.
662+ A :exc: `OSError ` is raised for errors from the call to :func: `inet_ntop `.
656663
657664 Availability: Unix (maybe not all platforms), Windows.
658665
659666 .. versionchanged :: 3.4
660667 Windows support added
661668
669+ .. versionchanged: 3.5
670+ Writable :term:`bytes-like object` is now accepted.
671+
662672
663673..
664674 XXX: Are sendmsg(), recvmsg() and CMSG_*() available on any
@@ -1207,11 +1217,15 @@ to sockets.
12071217
12081218 Set the value of the given socket option (see the Unix manual page
12091219 :manpage: `setsockopt(2)`). The needed symbolic constants are defined in the
1210- :mod: `socket ` module (:const: `SO_\* ` etc.). The value can be an integer or a
1211- bytes object representing a buffer. In the latter case it is up to the caller to
1220+ :mod: `socket ` module (:const: `SO_\* ` etc.). The value can be an integer or
1221+ a :term: `bytes-like object ` representing a buffer. In the latter case it is
1222+ up to the caller to
12121223 ensure that the bytestring contains the proper bits (see the optional built-in
12131224 module :mod: `struct ` for a way to encode C structures as bytestrings).
12141225
1226+ .. versionchanged: 3.5
1227+ Writable :term:`bytes-like object` is now accepted.
1228+
12151229
12161230 .. method :: socket.shutdown(how)
12171231
0 commit comments