Skip to content

Commit fdcb675

Browse files
akulakovambv
andauthored
bpo-40635: Fix getfqdn() docstring and docs (GH-27971)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
1 parent f9cd40f commit fdcb675

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Doc/library/socket.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,8 +808,9 @@ The :mod:`socket` module also offers various network-related services:
808808
it is interpreted as the local host. To find the fully qualified name, the
809809
hostname returned by :func:`gethostbyaddr` is checked, followed by aliases for the
810810
host, if available. The first name which includes a period is selected. In
811-
case no fully qualified domain name is available, the hostname as returned by
812-
:func:`gethostname` is returned.
811+
case no fully qualified domain name is available and *name* was provided,
812+
it is returned unchanged. If *name* was empty or equal to ``'0.0.0.0'``,
813+
the hostname from :func:`gethostname` is returned.
813814

814815

815816
.. function:: gethostbyname(hostname)

Lib/socket.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -782,8 +782,9 @@ def getfqdn(name=''):
782782
An empty argument is interpreted as meaning the local host.
783783
784784
First the hostname returned by gethostbyaddr() is checked, then
785-
possibly existing aliases. In case no FQDN is available, hostname
786-
from gethostname() is returned.
785+
possibly existing aliases. In case no FQDN is available and `name`
786+
was given, it is returned unchanged. If `name` was empty or '0.0.0.0',
787+
hostname from gethostname() is returned.
787788
"""
788789
name = name.strip()
789790
if not name or name == '0.0.0.0':

0 commit comments

Comments
 (0)