This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: documentation on `getsockname()` wrong for AF_INET6
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, miss-islington, vanrein
Priority: normal Keywords: patch

Created on 2020-12-11 11:49 by vanrein, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 23742 merged christian.heimes, 2020-12-11 14:17
PR 23906 merged miss-islington, 2020-12-23 07:26
PR 23907 merged miss-islington, 2020-12-23 07:26
Messages (6)
msg382863 - (view) Author: Rick van Rein (vanrein) Date: 2020-12-11 11:49
Shown in the session below is unexpected output of a 4-tuple from an AF_INET6 socket along with documentation that *suggests* to expect a 2-tuple.  The phrasing "IP" might have to be toned down to "IPv4" or "AF_INET" to be accurate enough to avoid confusion.

Opinion: I think you should be explicit about the different behaviour for AF_INET6, so it is not reduced to a special/nut case for special interest groups.  IPv6 has a hard enough time getting in; different formats for AF_INET and AF_INET6 should ideally be shown to all programmers, to at least avoid *uninformed* decisions to be incompatible with IPv6 while they develop on an IPv4 system (and the same in the opposite direction).


Python 3.7.3 (default, Jul 25 2020, 13:03:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> sox6 = socket.socket (socket.AF_INET6)
>>> sox6.getsockname ()
('::', 0, 0, 0)
>>> sox6.getsockname.__doc__
'getsockname() -> address info\n\nReturn the address of the local endpoint.  For IP sockets, the address\ninfo is a pair (hostaddr, port).'
msg382868 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2020-12-11 14:21
Good point. The address info depends on the address family, https://docs.python.org/3/library/socket.html#socket-families . I have updated the doc string:

>>> import socket
>>> print(socket.socket.getsockname.__doc__)
getsockname() -> address info

Return the address of the local endpoint. The format depends on the
address family. For IPv4 sockets, the address info is a pair
(hostaddr, port).
msg382875 - (view) Author: Rick van Rein (vanrein) Date: 2020-12-11 17:12
Excellent, thanks.  I personally would appreciate if a remark about IPv6 would also be made.
msg383633 - (view) Author: miss-islington (miss-islington) Date: 2020-12-23 07:26
New changeset cf3565ca9a7ed0f7decd000e41fa3de400986e4d by Christian Heimes in branch 'master':
bpo-42620: Improve socket.getsockname doc string (GH-23742)
https://github.com/python/cpython/commit/cf3565ca9a7ed0f7decd000e41fa3de400986e4d
msg383634 - (view) Author: miss-islington (miss-islington) Date: 2020-12-23 07:44
New changeset b20494618c6ac6ebcd354e0b16a6645fe47acbee by Miss Islington (bot) in branch '3.8':
bpo-42620: Improve socket.getsockname doc string (GH-23742)
https://github.com/python/cpython/commit/b20494618c6ac6ebcd354e0b16a6645fe47acbee
msg383635 - (view) Author: miss-islington (miss-islington) Date: 2020-12-23 07:48
New changeset 7fe7d83c26b02c8a65c8a9633cc4251f5cd97ebf by Miss Islington (bot) in branch '3.9':
bpo-42620: Improve socket.getsockname doc string (GH-23742)
https://github.com/python/cpython/commit/7fe7d83c26b02c8a65c8a9633cc4251f5cd97ebf
History
Date User Action Args
2022-04-11 14:59:39adminsetgithub: 86786
2020-12-23 07:48:14miss-islingtonsetmessages: + msg383635
2020-12-23 07:44:25miss-islingtonsetmessages: + msg383634
2020-12-23 07:26:29miss-islingtonsetpull_requests: + pull_request22760
2020-12-23 07:26:21miss-islingtonsetpull_requests: + pull_request22759
2020-12-23 07:26:00miss-islingtonsetnosy: + miss-islington
messages: + msg383633
2020-12-11 17:12:26vanreinsetmessages: + msg382875
2020-12-11 14:21:11christian.heimessetmessages: + msg382868
versions: + Python 3.8, Python 3.9, Python 3.10, - Python 3.7
2020-12-11 14:17:39christian.heimessetkeywords: + patch
nosy: + christian.heimes

pull_requests: + pull_request22600
stage: patch review
2020-12-11 11:49:59vanreincreate