]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40635: Fix getfqdn() docstring and docs (GH-27971)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 26 Aug 2021 19:54:52 +0000 (12:54 -0700)
committerGitHub <noreply@github.com>
Thu, 26 Aug 2021 19:54:52 +0000 (12:54 -0700)
Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
(cherry picked from commit fdcb675eed47b1f6054fae381af4388b16a6fff4)

Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
Doc/library/socket.rst
Lib/socket.py

index e1db1b5e66629e6f769e1f4a0c6a981210f52b05..1b6dc4d1ed08dcadc5b2d2aa9501823e6e1588f0 100755 (executable)
@@ -808,8 +808,9 @@ The :mod:`socket` module also offers various network-related services:
    it is interpreted as the local host.  To find the fully qualified name, the
    hostname returned by :func:`gethostbyaddr` is checked, followed by aliases for the
    host, if available.  The first name which includes a period is selected.  In
-   case no fully qualified domain name is available, the hostname as returned by
-   :func:`gethostname` is returned.
+   case no fully qualified domain name is available and *name* was provided,
+   it is returned unchanged.  If *name* was empty or equal to ``'0.0.0.0'``,
+   the hostname from :func:`gethostname` is returned.
 
 
 .. function:: gethostbyname(hostname)
index fc11eb783c3dd104d1ceaecc7d04c3cb301b7b83..63ba0acc908c3c08c2a26bb47d3987fdf501afda 100755 (executable)
@@ -782,8 +782,9 @@ def getfqdn(name=''):
     An empty argument is interpreted as meaning the local host.
 
     First the hostname returned by gethostbyaddr() is checked, then
-    possibly existing aliases. In case no FQDN is available, hostname
-    from gethostname() is returned.
+    possibly existing aliases. In case no FQDN is available and `name`
+    was given, it is returned unchanged. If `name` was empty or '0.0.0.0',
+    hostname from gethostname() is returned.
     """
     name = name.strip()
     if not name or name == '0.0.0.0':